From 7e3bd7f9aac217ac5f3f865c49ca97c303414e6d Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Tue, 24 Aug 2010 00:02:12 -0400 Subject: [PATCH] Windows: Fix use of file descriptors as sockets Sockets and file descriptors are not interchangeable on Windows. The test for checking whether a given value is a socket or an FD was broken for the case where WinSock was not initialized to begin with. --- lib/roken/net_read.c | 3 ++- lib/roken/net_write.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/roken/net_read.c b/lib/roken/net_read.c index 1f959db95..df1ac53de 100644 --- a/lib/roken/net_read.c +++ b/lib/roken/net_read.c @@ -86,7 +86,8 @@ net_read(rk_socket_t sock, void *buf, size_t nbytes) if (use_read == 0 && rk_IS_SOCKET_ERROR(count) && - rk_SOCK_ERRNO == WSAENOTSOCK) { + (rk_SOCK_ERRNO == WSANOTINITIALISED || + rk_SOCK_ERRNO == WSAENOTSOCK)) { use_read = 1; count = _read (sock, cbuf, rem); diff --git a/lib/roken/net_write.c b/lib/roken/net_write.c index 402e20915..e1cfa9907 100644 --- a/lib/roken/net_write.c +++ b/lib/roken/net_write.c @@ -83,7 +83,8 @@ net_write(rk_socket_t sock, const void *buf, size_t nbytes) if (use_write == 0 && rk_IS_SOCKET_ERROR(count) && - rk_SOCK_ERRNO == WSAENOTSOCK) { + (rk_SOCK_ERRNO == WSANOTINITIALISED || + rk_SOCK_ERRNO == WSAENOTSOCK)) { use_write = 1; count = _write (sock, cbuf, rem); -- 2.11.4.GIT