Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [QT5] QTcpServer with multithreading

[QT5] QTcpServer with multithreading

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qt5beginner
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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 ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qt5beginner
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qt5beginner
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved