hi there! this is my first post let's start!

i've read almost all posts about QThread, QTcpServer & QTcpSocket, but still have some problems.
i wanna advice in the subject & all around

the main idea is to write multithreaded app using QTcpServer & QTcpSocket.

here's little bit of code:

client class
Qt Code:
  1. class TClient : public QTcpSocket
  2. {
  3. public:
  4. TClient()
  5. {
  6. connect( this, SIGNAL( connected() ), this, SLOT( connectedSlot() ) );
  7. connect( this, SIGNAL( disconnected() ), this, SLOT( disconnectedSlot() ) );
  8. }
  9.  
  10. private slots:
  11. void connectedSlot() { emit connected( this ); }
  12. void disconnectedSlot() { emit disconnected( this ); }
  13.  
  14. signals:
  15. void connected( TClient * );
  16. void disconnected( TClient * );
  17. };
To copy to clipboard, switch view to plain text mode 

thread class
Qt Code:
  1. class TClientThread : public QThread
  2. {
  3. public:
  4. TClientThread( TClient *client ) : m_Client( client ) {}
  5. ~TClientThread()
  6. {
  7. wait();
  8. }
  9.  
  10. protected:
  11. void run()
  12. {
  13. connect( m_Client, SIGNAL( destroyed() ), this, SLOT( quit() ) );
  14. exec();
  15. }
  16.  
  17. private:
  18. TClient *m_Client;
  19. };
To copy to clipboard, switch view to plain text mode 

server class
Qt Code:
  1. class TServer : public QTcpServer
  2. {
  3. protected:
  4. void incomingConnection( int socketDescriptor )
  5. {
  6. TClient *client = new TClient;
  7. // assuming no error
  8. client->setSocketDescriptor( socketDescriptor );
  9. connect( client, SIGNAL( connected( TClient * ) ), this, SLOT( clientConnected( TClient * ) ), Qt::QueuedConnection );
  10. connect( client, SIGNAL( disconnected( TClient * ) ), this, SLOT( clientDisconnected( TClient * ) ), Qt::QueuedConnection );
  11.  
  12. TClientThread *thread = new TClientThread( client );
  13. connect( thread, SIGNAL( finished() ), this, SLOT( killThread() ) );
  14. client->moveToThread( thread );
  15. thread->start();
  16.  
  17. emit clientConnected( client );
  18. }
  19.  
  20. signals:
  21. void clientConnected( TClient * );
  22. void clientDisconnected( TClient * );
  23.  
  24. private slots:
  25. void killThread()
  26. {
  27. delete sender();
  28. }
  29. };
To copy to clipboard, switch view to plain text mode 

i call client->deleteLater() in the slot connected to TServer::clientDisconnected( TClient * );

1) is the 13th line in server class good idea or not?

2) may be better to move thread creation & moving client to thread from incomingConnection() to the slot connected to TServer::clientDisconnected( TClient * ) signal?

3) i need to obtain data from clientThread from other thread. data would be represented by char *[1-16 kBytes]? client receives data uninterruptedly, another thread process this data. i don't want client to be able to know anything about extern queue or mutex...
do you know some design pattern to use in this case or with threads in general?

4) i designed client anisochronous because i wanna use it either in main or spawned thread. it has relationship with 2)

thanks for your attention