Qt-interest Archive, June 2007
[QTcpServer] can't read data from nextPendingConnection()
Message 1 in thread
Hi all,
I'm having some trouble to read from a QTcpSocket returned by QTcpServer. The
situation is like this:
1) Server listens
2) Client connects and sends a message to identify itself
3) Server creates a Client object using the data in this message
The problem is #3, a QTcpSocket is returned when calling
nextPendingConnection() and the message from the client has been sent
correctly. Though the bytesAvailable() function on the returned QTcpSocket
keeps returning 0. With as a result that I can't read the message obviously
and thus can't create the client object. If I check with "netstat -an --inet"
it says that the data still is in the Recv-Q.
The weird thing is, that when I immediately create a thread to handle the
newly returned QTcpSocket I can read from the socket just fine. But since the
client object is a thread itself it seems pretty bad to create another thread
just to handle the message so I can extract the data.
Is there anyone who has encountered this before and possibly knows a
workaround? I'm willing to post a testcase which probably will illustrate the
problem better.
Best regards,
Sander Knopper
--
[ signature omitted ]