Using a tcp connection, you can never know how many packages are send until a message is submitted. But you can let Qt handle that stuff. You nedd to implement something like this:
connect( m_pTcpServer, SIGNAL( newConnection()), SLOT( solt_newConnection()) );
void CTcpManager::solt_newConnection() {
m_pTcpSocket = m_pTcpServer->nextPendingConnection();
connect( m_pTcpSocket, SIGNAL(readyRead()), this, SLOT( slot_startRead() ) );
}
void CTcpManager::slot_startRead() {
QByteArray grDatagram;
grDatagram = m_pTcpSocket->readAll();
// Process data
m_pTcpSocket->close();
}