I wrote a C++ application which can act as both server and a client depending upon command line arguments. So, the client will initiate a connection and the server will accept and the data transfer will take place, and I will always have one pending WSARecv call with 2KB buffer. Till here this is fine.
But let's say I call shutdown and closesocket on client, then GetQueuedCompletionStatus fails with error ERROR_CONNECTION_ABORTED (0x40) on the client side and on the server side it fails with error ERROR_NETNAME_DELETED (0x64).
Here is the code for closing the socket
shutdown(sock, SD_RECEIVE);
closesocket(sock);
But lets say, I send a request to server from Postman application, I notice when Postman receives a response from server it closes the socket, and GetQueuedCompletionStatus doesn't fail and I get a IO Completion packet, with the lpNumberOfBytesTransferred as zero.
What is the reason for this change of behavior? Am i closing the sockets gracefully?
Also in wireshark I notice when my client closes the socket I see a RST packet, whereas Postman sends a FIN packet. What am I doing wrong?