Client closes before server receives
Okay, I have a client (using plain old winsock) connecting to a server (using CAsyncSocket). It first sends a message saying some data is coming, then it sends the data, then it closesocket()'s the connection. What happens serverside is it receives the "data on the way" message in OnReceive() then on the next OnReceive() (for the transfer of the actual data), Receive() returns SOCKET_ERROR with a GetLastError() of WSAENOTSOCK. So I finally figured out that the reason this happens is that the client's closure of the socket after the send apparently screws the server out of getting the data. Is this what's actually happening?
I suppose a simple way around it is to just always make sure the server has the last word by sending an OK_TO_QUIT message to the client before he closes, but is there another way around it?
Your thoughts are appreciated.