[Qt-interest] sockets and threads on linux

pmqt71 pmqt71 at gmail.com
Sun Feb 13 17:42:06 CET 2011


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/20110213/2f655d3d/attachment.html 


More information about the Qt-interest-old mailing list