Return values on API failure

The manifest constant SOCKET_ERROR is provided for checking API failure. Although use of this constant is not mandatory, it is recommended. The following example illustrates the use of the SOCKET_ERROR constant:

TYPICAL BSD STYLE:

r = recv(...);
if (r == -1     /* or r < 0 */
    && errno == EWOULDBLOCK)
        {...}

PREFERRED STYLE:

r = recv(...);
if (r == SOCKET_ERROR
    && WSAGetLastError() == WSAEWOULDBLOCK)
        {...}


[Back: Include files]
[Next: Raw Sockets]