Hello everybody,
i have a strange pbm here. I have QTcpServer Which do listening accepting new connections putting data on dialog level. I have fortune client type code which transfers the data to server.
I have few problems here.Major problem is QTcpServer is not reading as fastly as client is writing.

code for server is
Qt Code:
  1. void MyDialog::settingServer()
  2. {
  3. tcpServer=new QTcpServer(this);
  4. if(!(tcpServer->listen(QHostAddress::Any,35000)))
  5. { cout<<"\n Tcp Server not listening";
  6. QMessageBox::critical(this,tr("server"),tr(" not able to start"));
  7. }
  8. else
  9. {
  10. int x=tcpServer->serverPort();
  11. label->setText(QString("Server is listening on port ")+QByteArray::number(x));
  12. connect(tcpServer,SIGNAL(newConnection()),this,SLOT(activatingNewConnection()));
  13. }
  14. }
  15.  
  16. MyDialog::~MyDialog()
  17. {
  18.  
  19. }
  20.  
  21. void MyDialog::activatingNewConnection()
  22. {
  23. tcpSocket=tcpServer->nextPendingConnection();
  24. connect(tcpSocket, SIGNAL(disconnected()),tcpSocket, SLOT(deleteLater()));
  25. connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(dataAvailable()));
  26.  
  27.  
  28. }
  29.  
  30. void MyDialog::dataAvailable()
  31. {
  32.  
  33. QDataStream in(tcpSocket);
  34. in.setVersion(QDataStream::Qt_4_0);
  35. if(tcpSocket->bytesAvailable() <= 0 )
  36. {
  37. //cout<<"\nNothing Available for reading";
  38. return;
  39. }
  40. QString st;bool ok;
  41. int i;
  42. in >> st;
  43. label->setText(st);
  44.  
  45. }
To copy to clipboard, switch view to plain text mode 
important code for client is
Qt Code:
  1. void Client::sendingData(int x,int y)
  2. {
  3. QByteArray block;
  4. QDataStream stream(&block,QIODevice::ReadWrite);
  5. stream.setVersion(QDataStream::Qt_4_0);
  6. QString temp;
  7.  
  8. temp = QString( QString(QByteArray::number(x)));
  9.  
  10. stream.device()->seek(0);
  11. stream << temp;
  12. cout<<"\n"<<temp.toInt()<<endl;
  13. QString st="he;llo world";
  14. cout<<st.data()<<endl;
  15. if(tcpSocket->write(block)==-1)
  16. QMessageBox::critical(this,tr("Socket Warning"),tr("Not able to write to socket"));
  17. else
  18. {
  19. statusLabel->setText(tr("Hi")+QString(QByteArray::number(x)));
  20.  
  21. }
  22. temp = QString(QString(QByteArray::number(y)));
  23. stream << temp;
  24. cout<<temp.toInt();
  25. if(tcpSocket->write(block)==-1)
  26. QMessageBox::critical(this,tr("Socket Warning"),tr("Not able to write to socket"));
  27. else
  28. {
  29. statusLabel->setText(tr("Hi")+QString(QByteArray::number(y)) );
  30.  
  31. }
  32. }
To copy to clipboard, switch view to plain text mode 

i need guidance on one more issue, Say multiple clients get connected to socket. How i will diffrentiate between the data which i receives from various sockets.
i think above code can cater to multiple clients.

cya
quick nitin