Guenter Knauf submitted code to detect on windows if the socket is

blocking or not
This commit is contained in:
James Housley
2007-06-22 16:46:36 +00:00
parent 639b29631a
commit 25adcc150e
2 changed files with 20 additions and 2 deletions

View File

@@ -318,6 +318,20 @@ static int _libssh2_get_socket_nonblocking(int sockfd) /* operate on this */
#define GETBLOCK 1
#endif
#if defined(WSAEWOULDBLOCK) && (GETBLOCK == 0)
/* Windows? */
unsigned int option_value;
socklen_t option_len = sizeof(option_value);
if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&option_value, &option_len)) {
/* Assume blocking on error */
return 1;
}
return (int)option_value;
#undef GETBLOCK
#define GETBLOCK 2
#endif
#if defined(HAVE_SO_NONBLOCK) && (GETBLOCK == 0)
/* BeOS */
long b;