- // if error encountered
- if ( readResult == SOCKET_ERROR ) {
- const int errorCode = WSAGetLastError();
- switch ( errorCode ) {
- case WSAEWOULDBLOCK: // nothing read this time, but more coming later
- return -2;
- default:
- return -1; // on any other errors
- }
- }
-
- // check if nothing was read this time, but more is coming
- if ( WSAGetLastError() == WSAEWOULDBLOCK )
- return -2;
-
- // otherwise return number of bytes read