class Server : public QTcpServer{..void incomingConnection( int sock ){ QTcpSocket * s = new QTcpSocket( this ); s->setSocketDescriptor( sock ); s->write( "server", 7 );}..};void SomeClass::someFunc(){ s = new QTcpSocket( this ); connect( s, SIGNAL(connected()), SLOT(connected()) ); s->connectToHost( "localhost", 1234 );}void SomeClass::connected(){ s->write( "client", 7 );}