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. QTcp socket multi threaded application
Forum Updated to NodeBB v4.3 + New Features

QTcp socket multi threaded application

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    suhas.ga
    wrote on last edited by
    #1

    I have created a multithreaded qtcpserver which creates a new thread whenever a new incomming connection occurs . But when i get the data readyread signal is sometimes getting emitted and sometimes it is not getting emitted...

    Does anyone knows anything about this issue.??

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      How do you know it is not emitted? How did you connect to the new threads?
      Some code might give some insights.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • S Offline
        S Offline
        suhas.ga
        wrote on last edited by
        #3

        I have kept a debug print in the readyread signal. When I am using in ubuntu it is sometimes printing and sometime not printing. In windows it is working .

        This is the way I am creating the thread

        NewConnection *newCon = new NewConnection(sock->socketDescriptor(),PresentTablesCount);
        qDebug()<<sock->socketDescriptor();
        connect(newCon,SIGNAL(finished()),newCon,SLOT(deleteLater()));
        newCon->start();

        in thread run i am using in this way

        socket = new QTcpSocket();
        if(!socket->setSocketDescriptor(this->socketDescriptor))
        {
        qDebug()<<"error in setting sock desc";
        return;
        }
        connect(socket, SIGNAL(readyRead()), this, SLOT(OnReadyRead()), Qt::DirectConnection);
        connect(socket, SIGNAL(disconnected()), this, SLOT(OnDisconnected()));
        exec();

        ReadyRead slot

        qDebug()<<"in ready read";
        QByteArray = socket->readAll();

        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