I've never actually used shutdown() before, and my programs seem to be running ok (although, to be sure, they aren't the best either). So what exactly happens if you don't recv() all the data before calling closesocket()? I've always just checked for a recv() returning zero on the other end, to see if the socket has been disconnected, and I haven't ran into any problems yet.
To assure that all data is sent and received on a connected socket before it is closed, an application should use shutdown to close connection before calling closesocket. For example, to initiate a graceful disconnect:
1. Call WSAAsyncSelect to register for FD_CLOSE notification.
2. Call shutdown with how=SD_SEND.
3. When FD_CLOSE received, call recv until zero returned, or SOCKET_ERROR.
4. Call closesocket.