Hello everyone,
could someone tell me the reason for the code below does not send the data? I think that the data is being buffered, rather than sent
int type_msg = 6;
data.append( (char*)&type_msg, sizeof(int) );
string video_server_address;
in >> video_server_address;
int num_char_video_server_address = video_server_address.size();
data.append( (char*)&num_char_video_server_address, sizeof(int) );
data.
append( QString(video_server_address.
c_str()) );
int num_bytes_write = clientSocket->write( data.data(), data.size() );
clientSocket->flush();
while( clientSocket->bytesToWrite() > 0 ){
num_bytes_write += clientSocket->write( data.data()+num_bytes_write, data.size()-num_bytes_write );
clientSocket->flush();
clientSocket->waitForBytesWritten();
}
QByteArray data;
int type_msg = 6;
data.append( (char*)&type_msg, sizeof(int) );
string video_server_address;
in >> video_server_address;
int num_char_video_server_address = video_server_address.size();
data.append( (char*)&num_char_video_server_address, sizeof(int) );
data.append( QString(video_server_address.c_str()) );
int num_bytes_write = clientSocket->write( data.data(), data.size() );
clientSocket->flush();
while( clientSocket->bytesToWrite() > 0 ){
num_bytes_write += clientSocket->write( data.data()+num_bytes_write, data.size()-num_bytes_write );
clientSocket->flush();
clientSocket->waitForBytesWritten();
}
To copy to clipboard, switch view to plain text mode
before this code a lot of data has been sent successfully the same way, but these last 17 bytes were not received by the client
clientSocket is a variable whose type is QTcpSocket.
Thanks
Bookmarks