[Qt-interest] sockets and threads on linux

william.crocker at analog.com william.crocker at analog.com
Tue Feb 15 00:06:36 CET 2011


Some detail omitted   :-)

1 - Subclass QTcpServer and redefine incomingConnection(int)
     ( The QTcpServer runs in the main thread. )

2 - In this function, create a thread and pass it the int file descriptor.

3 - In the ::run method of the thread, create a ::run/local QTcpSocket and
     setSocketDescriptor with the incoming file desc.

4 - Create some other ::run/local object to handle the readyRead()

5 - Create and ::exec an event loop.

I have a server which has been running flawlessly
under this scenario for years.

Bill

> On Monday, 14 de February de 2011 19:43:34 Francisco Gonzalez wrote:
>> In your implementation details both signal readyRead() and slot
>> onReadyRead()  are members of your MyTcpSocket class, so when you move the
>> pSocket object to the QThread th, you are moving both the signal, and the
>> processing function. I do not understand how can it improve the socket
>> capability of processing, as both functions live in the same thread.
> 



More information about the Qt-interest-old mailing list