how to format it? what are those rules?
Added after 1 11 minutes:

Originally Posted by
wysota
Then do it with regular C calls, nobody forces you to use Qt classes for that. With plain C calls you'll be having the exact same "problems" you have now -- you will have to format the data somehow and read it somehow according to all rules that govern asynchronous communication between two autonomous systems.
I think you are wrong. As I tested the program in another system, with standard c++ rcv function, it could receive the image.
So, that means the send or write commands is correct and client program works fine:
clientSocket->write((char*)&size, 4);
clientSocket->write(blob.data(), size);
clientSocket->write((char*)&size, 4);
clientSocket->write(blob.data(), size);
To copy to clipboard, switch view to plain text mode
However, this shows the server program written (the first one) is not correct, which is quite strange. As I debugged it, it received the packet up to 50 KB and then returns 0! On the other, the other one which used std sockets, can read all of it.
int size;
clientConnection->read((char*)&size, 4);
qDebug() << size;
char* image;
qDebug() << size;
image = new char[size];
int size2 = size;
int offset = 0;
while(size2 > 0)
{
int r = clientConnection->read(image+offset, size2);
if(r == 0)
break;
size2 -= r;
offset += r;
}
int size;
clientConnection->read((char*)&size, 4);
qDebug() << size;
char* image;
qDebug() << size;
image = new char[size];
int size2 = size;
int offset = 0;
while(size2 > 0)
{
int r = clientConnection->read(image+offset, size2);
if(r == 0)
break;
size2 -= r;
offset += r;
}
To copy to clipboard, switch view to plain text mode
Bookmarks