Search code examples
c++socketsiocp

Does all error codes of WSASend() and WSARecv() means that the socket has disconnected?


I need to know if the error codes of WSASend() and WSARecv() (except for WSA_IO_PENDING) when using IOCP means that the socket has disconnected. Most of the error codes are obvious, however I am not sure about the following:

Error codes of WSASend():

  • WSAEINPROGRESS
  • WSAENOBUFS
  • WSA_OPERATION_ABORTED

Error codes of WSARecv():

  • WSAEFAULT
  • WSAEINPROGRESS

Solution

  • The Answer

    No, not all error codes is because of a disconnected socket.


    Elaboration

    I'm actually not sure how to answer this question without yelling out "No, read the documentation!".


    As an example, WSAEINPROGRESS means that there's another blocking operation in progress - so the current one has been aborted because of that.

    WSAEINPROGRESS - 10036

    Operation now in progress.

    A blocking operation is currently executing. Windows Sockets only allows a single blocking operation—per- task or thread—to be outstanding, and if any other function call is made (whether or not it references that or any other socket) the function fails with the WSAEINPROGRESS error.