Important: Please read the Qt Code of Conduct -

[QT5] QTcpServer with multithreading

  • hi,

    i have got a problem. i tried the tutorial from this site and it works fine.

    but everytime when i changed the line

    in "mythread.cpp" i don't get a message (response) from the tcpserver.

    @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 :)

  • Qt Champions 2017

    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 ( 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.

Log in to reply