[Qt-interest] sockets and threads on linux

pmqt71 pmqt71 at gmail.com
Mon Feb 14 00:50:37 CET 2011


this was my previous implementation but it wasn't working properly because
the socket was living in the main thread. The moveTothread solved, now there
is a new problem on linux.
thanks
pm



2011/2/13 <markus.goetz at nokia.com>

> Create the actual object (the QTcpSocket) in the other thread instead of
> moving it.
> ________________________________________
> From: qt-interest-bounces+markus.goetz=nokia.com at qt.nokia.com[qt-interest-bounces+markus.goetz=
> nokia.com at qt.nokia.com] On Behalf Of ext pmqt71 [pmqt71 at gmail.com]
> Sent: Sunday, February 13, 2011 5:42 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] sockets and threads on linux
>
> Hi all,
> Hi Qt people, I hope the best for Qt and you!
>
> I have a tcp client server program working well on WinXP, but not on linux.
>
> MyTcpServer inherits from QTcpServer. the incomingConnection method creates
> a new socket and moves it to a new thread. The socket is handled by
> MyTcpSocket that inherits from QTcpSocket and implements the slots to manage
> client's incoming data:
>
> void MyTcpServer::incomingConnection(int socketDescriptor)
> {
>   MyTcpSocket *pSocket = new MyTcpSocket();
>
>   if (!pSocket->setSocketDescriptor(socketDescriptor)) {
>       qDebug() << "MyTcpServer::incomingConnection:" << pSocket->error();
>       return;
>   }
>
>   connect(pSocket, SIGNAL(readyRead()), pSocket, SLOT(onReadyRead()));
>   connect(pSocket, SIGNAL(disconnected()), pSocket,
> SLOT(onSocketDisconnect()));
>
>   QThread *th = new QThread(this);
>   pSocket->moveToThread(th);
>
>   th->start();
> }
>
> On WinXP all is working fine, and I get the readyRead signal as a client
> writes.
> On linux (Ubuntu 9.04 64bit) the readyRead signal is not fired. The
> incomingConnection is completed with no error, the pSocket objects gets the
> event ThreadChange related to the moveToThread operation. Nothing else.
> How can I debug?
> Qt 4.6.2
>
> thanks
> pm
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110214/e74bd09f/attachment.html 


More information about the Qt-interest-old mailing list