Qt World Summit: Submit your Presentation

QTcp socket multi threaded application

  • 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.??

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

  • 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);

    in thread run i am using in this way

    socket = new QTcpSocket();
    qDebug()<<"error in setting sock desc";
    connect(socket, SIGNAL(readyRead()), this, SLOT(OnReadyRead()), Qt::DirectConnection);
    connect(socket, SIGNAL(disconnected()), this, SLOT(OnDisconnected()));

    ReadyRead slot

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

Log in to reply