
Originally Posted by
probine
How can I collect all the image coming from the remote computer in my QByteArray before passing the image to the label ?
You need something like this:
void ClientThread :: readData()
{
buffer.append( tcpSocket->readAll() );
int messageSize = 0;
do {
messageSize = parseMessage( buffer );
buffer.remove( 0, messageSize );
}
while( messageSize > 0 );
}
void ClientThread :: readData()
{
buffer.append( tcpSocket->readAll() );
int messageSize = 0;
do {
messageSize = parseMessage( buffer );
buffer.remove( 0, messageSize );
}
while( messageSize > 0 );
}
To copy to clipboard, switch view to plain text mode
There are three possibilities:- the buffer contains only a part of a message (in this case parseMessage() should only return 0),
- the buffer contains a message followed by a part of another message (in this case parseMessage() should parse that message and return its size),
- the buffer contains an invalid message (it might happen due some communication errors or bugs on the other side).
Bookmarks