I have server and client in the same client/server architecture application.

First send
Server::incommingConnection()
Buffering
"Task::handleTask strBuffer= taskToHandle---received from localhost:1591"

"RequestManager::send() response SENDING TO: localhost:1591"
RequestManager::send() CONNECTING...
RequestManager::send() CONNECTED
RequestManager::send() SENT!
New client connected


is debug output


now my problem is that it stops at New client connected and doesn't goto readyRead() infact even when I explicitely call readyRead() [my slot connected to QTcpSocket's readyRead signal] readAll() has nothing in it

following diagram is better way of describing of whats happening:

server_response.png

Following are some bits of my code:

Qt Code:
  1. void Server::incomingConnection(const int socketDescriptor)
  2. {
  3. #if (DEBUGGING)
  4. qDebug()<<"Server::incommingConnection()";
  5. #endif
  6. client=new NetworkObjects::Client(socketDescriptor,parent_);
  7.  
  8. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. Client::Client(const int socketDescriptor,QObject *parent) :
  2. QObject(parent),
  3. parent_(parent)
  4. {
  5. setSocketDescriptor(socketDescriptor);
  6. //initialize socket
  7. this->tcpSocket = new QTcpSocket(this);
  8. tcpSocket->open(QTcpSocket::ReadWrite);
  9.  
  10. //connect signals/slots of socket
  11. QObject::connect(tcpSocket,SIGNAL(connected()),this,SLOT(connected()));
  12. QObject::connect(tcpSocket,SIGNAL(disconnected()),this,SLOT(disconnected()));
  13. QObject::connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(readyRead()));
  14.  
  15.  
  16. this->tcpSocket->setSocketDescriptor(this->socketDescriptor());
  17. if (this->tcpSocket->waitForReadyRead(kWaitConnectingMillisecond))
  18. qDebug()<<"New client connected";
  19. else
  20. qDebug()<<"Error while connecting client: "+tcpSocket->errorString();
  21. }
To copy to clipboard, switch view to plain text mode 

printing this tcpSocket->errorString() gives error "The remote host closed the connection".
I even tried to comment out all closing statements that closes socket (for debugging purpose) but didn't do

Qt Code:
  1. void Client::readyRead(void)
  2. {
  3. qDebug()<<"Buffering";
  4. NetworkObjects::Task *task=new NetworkObjects::Task(parent_,tcpSocket->readAll());
  5. QObject::connect(task,SIGNAL(taskCompleted()),task,SLOT(deleteLater()));
  6. task->handleTask();
  7.  
  8. }
To copy to clipboard, switch view to plain text mode 

see the app instance 1 in above image sends request successfully and app instance 2 receives it fine and creates response

Qt Code:
  1. void RequestManager::send(QByteArray *request)
  2. {
  3. #if (DEBUGGING)
  4. qDebug()<<"RequestManager::send() " + QString(*request) + " SENDING TO: "+address_+":"+QString::number(port_);
  5. #endif
  6. sendTcpSocket->abort();
  7. sendTcpSocket->open(QTcpSocket::ReadWrite);
  8.  
  9. sendTcpSocket->connectToHost(address_,port_);
  10. #if (DEBUGGING)
  11. qDebug()<<"RequestManager::send() CONNECTING...";
  12. #endif
  13.  
  14. if (sendTcpSocket->waitForConnected(3000))
  15. {
  16. #if (DEBUGGING)
  17. qDebug()<<"RequestManager::send() CONNECTED";
  18. #endif
  19. }
  20.  
  21.  
  22. if (sendTcpSocket->isOpen()==false){
  23. emit socketCannotOpen();
  24. }
  25. else if (sendTcpSocket->isWritable())
  26. {
  27.  
  28.  
  29. sendTcpSocket->write(*request);
  30.  
  31. #if (DEBUGGING)
  32. qDebug()<<"RequestManager::send() SENT!";
  33. #endif
  34. }
  35.  
  36. // sendTcpSocket->close();
  37.  
  38. }
To copy to clipboard, switch view to plain text mode 


can we please try to help me out?

thanks