diff --git a/src/packet.c b/src/packet.c index df8b697..0e8725e 100644 --- a/src/packet.c +++ b/src/packet.c @@ -640,9 +640,9 @@ static int libssh2_blocking_read(LIBSSH2_SESSION *session, unsigned char *buf, s #ifdef WIN32 switch (WSAGetLastError()) { case WSAEWOULDBLOCK: errno = EAGAIN; break; + case WSAENOTSOCK: errno = EBADF; break; case WSAENOTCONN: - case WSAENOTSOCK: - case WSAECONNABORTED: errno = EBADF; break; + case WSAECONNABORTED: errno = ENOTCONN; break; case WSAEINTR: errno = EINTR; break; } #endif @@ -680,7 +680,7 @@ static int libssh2_blocking_read(LIBSSH2_SESSION *session, unsigned char *buf, s if (errno == EINTR) { continue; } - if ((errno == EBADF) || (errno == EIO)) { + if ((errno == EBADF) || (errno == EIO) || (errno == ENOTCONN)) { session->socket_state = LIBSSH2_SOCKET_DISCONNECTED; } return -1; diff --git a/src/session.c b/src/session.c index 48e0f69..8ec39e7 100644 --- a/src/session.c +++ b/src/session.c @@ -109,11 +109,13 @@ static int libssh2_banner_receive(LIBSSH2_SESSION *session) case WSAEWOULDBLOCK: errno = EAGAIN; break; - case WSAENOTCONN: case WSAENOTSOCK: - case WSAECONNABORTED: errno = EBADF; break; + case WSAENOTCONN: + case WSAECONNABORTED: + errno = ENOTCONN; + break; case WSAEINTR: errno = EINTR; break;