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