Hello,

I want to implement a TCP client connection that can recieve messages and reponses. For that I use a Qqueue for putting the response of my request and I use the readyRead signal to see if there are incoming response/requests.

My code looks as follows


Qt Code:
  1. connect(tcpSocket,SIGNAL(readyRead()),this, SLOT(readData()));
  2.  
  3. ......
  4.  
  5. response_ptr Client:: sendRequest(QByteArray const &data) {
  6.  
  7. qDebug() << "Request: " << data.constData();
  8. tcpSocket->write(data);
  9. while(response_queue.isEmpty()) {}
  10. return response_ptr(response_queue.dequeue());
  11.  
  12. }
  13.  
  14. void Client::readData() {
  15.  
  16. .....
  17. // Read response an put it on the queue
  18.  
  19. response_queue.queue(response)
  20. }
  21.  
  22. .....
To copy to clipboard, switch view to plain text mode 

if I run the code and call "sendRequest", I come into a loop. Using wireShark I see that the request isn't send to the server.It seems that QT doesn't create a thread for listening to incoming data. I think that everything is running on the same thread ? So do I need to create a thread for listening on incoming messages/ responses ?