my server and client use WSAAsyncSelect to handle the sockets connection.
when my client connects to the server, the server sends an image of about 195,000 Bytes using 1 send() call.
for some reason, the client only rarely gets the entire image. usually it stops in the middle. I made a button that calls recv() on press. when i see the client has stopped getting packets, i press that button and it receives the remaining packets (about 40,000 Bytes).
if i try using my window handler after the client gets stuck, it crashes, so my conclusion is that for some reason the window handler being lost, and therefore WSAAsyncSelect stops sending messages about recv() calls.
The client needs to call recv in a loop cause the TCP subsystem is not able to serve such a huge buffer with one call. You will get the number of bytes read with each call and have to add the number of already received bytes to the buffer address passed with recv. Unfortunately, there is no safe way to find out when the read is complete beside the server has put the total size of bytes to send at the begin of the buffer where you can read it with the first call to recv.
The crashing probably is because the buffer provided by the client is too small.