[Qt-interest] sockets and threads on linux

pmqt71 pmqt71 at gmail.com
Tue Feb 15 13:49:37 CET 2011


Upgrading Qt to 4.7 solved the problem.

The target server was using Qt 4.5.0 shipped on Ubuntu repositories. Just as
information, the problem is only with Qt 4.5.0 64 bit, not with Qt 4.5.0 32.

thanks to all.
pm


p.s. Bill, as I experienced, your steps 2 and 3 make the socket live in the
main thread rather than in the one you create. I used moveToThread to
correctly move the QTcpSocket object to the dedicated thread. See my
previous messages where Thiago gave me the right suggestions.




2011/2/15 william.crocker at analog.com <william.crocker at analog.com>

> 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.
> >
>  _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110215/0ea3d468/attachment.html 


More information about the Qt-interest-old mailing list