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.
This commit is contained in:
Asanka Herath
2010-08-24 00:02:12 -04:00
committed by Asanka C. Herath
parent bd795255aa
commit 7e3bd7f9aa
2 changed files with 4 additions and 2 deletions

View File

@@ -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);

View File

@@ -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);