I am developing a simple Client/Server project which moves a chunk of data from client to server. I use TCP/IP.
The server sets up a listening socket and the client connects. First a short 16 byte "header" is transmitted containing some information including the amount of data to be transmitted after. Afterwards the big chunk is transmitted (around 2MB), namely
send( socketDesc, (void *) myBuffer, bigChunkSize, 0 );
and
recv( socketDescPeer, (void *) myBuffer, bigChunkSize, 0 )
First i implemented the client side under windows using winsock2, which works without problems. I now tried to port this implementation to linux, in which case the server side never returns from the recv() call (the "header" however is transmitted correctly). I then tried to send the data in smaller chunks of fixed size like this
unsigned int byteSent = 0;
while( byteSent < bigChunkSize ) {
int result = send( socketDesc, (void *) myBuffer, smallChunkSize, 0 );
if ( result < 0 ) {...} else { byteSent += result; }
}
Now, the server receives the first few number of chunks but then again, blocks.
Any ideas? Keep in mind that transmission works without problems using winsock2! Thanks a lot!
recv()
/read()
not returning? – alk Jun 12 at 16:22read()
/recv()
only blocks (on an blocking socket) if nothing is around to be read/received and the sender did not shut down the connection. – alk Jun 12 at 16:29