[QT5] QTcpServer with multithreading
-
hi,
i have got a problem. i tried the tutorial from this site http://www.bogotobogo.com/Qt/Qt5_QTcpServer_Multithreaded_Client_Server.php and it works fine.
but everytime when i changed the line
@socket->write(Data);@in "mythread.cpp" i don't get a message (response) from the tcpserver.
Example:
@void MyThread::readyRead()
{
// get the information
QByteArray Data = socket->readAll();// will write on server side window qDebug() << socketDescriptor << " Data in: " << Data; socket->write("TestString"); //no response...
}@
Has anyone an idea to help me? thanks a lot :)
-
Where did you create the socket variable ? Is it in main thread or worker thread ? Is severs running still ? Are you able to exchange data any time after establishing the connection ?
-
hi thanks for you answer.
my code looks exactly like the code in the tutorial. so i create the socket variable in the worker thread an the server is still running.
yes, i am able to exchange data. i can send any message with my client to the server. the server receives the message but doesn't send a response back (if i change the socket->write() statement, otherwise it works fine). -
i am using an android client (http://www.myandroidsolutions.com/2012/07/20/android-tcp-connection-tutorial/) and i found out with the telnet client of microsoft it works...
must i add something in the code of the tcpserver or is it an android problem? because i get the messages after i disconnect the android client from the server.