diff options
Diffstat (limited to 'NetEx/NetSock.cpp')
-rw-r--r-- | NetEx/NetSock.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/NetEx/NetSock.cpp b/NetEx/NetSock.cpp index 0fb1081..06cbdcc 100644 --- a/NetEx/NetSock.cpp +++ b/NetEx/NetSock.cpp @@ -122,7 +122,7 @@ NetSock::accept(NetAddr* addr) if (addr) { sockaddr a; int asize = sizeof(a); - + conn = ::accept(s, &a, &asize); if (conn != INVALID_SOCKET && asize > 0) { @@ -140,19 +140,19 @@ NetSock::accept(NetAddr* addr) } // +--------------------------------------------------------------------+ - + int NetSock::available() { if (closed || s == INVALID_SOCKET) return 0; - + DWORD nbytes = 0; if (::ioctlsocket(s, FIONREAD, &nbytes) == 0) return (int) nbytes; return 0; } - + // +--------------------------------------------------------------------+ int @@ -279,7 +279,7 @@ NetSock::set_timeout(int msecs) { if (closed || s == INVALID_SOCKET) return 0; if (msecs == current_timeout) return 1; - + // zero timeout means non-blocking if (msecs == 0) { u_long nonblocking = 1; @@ -288,7 +288,7 @@ NetSock::set_timeout(int msecs) return stat; } } - + // non-zero timeout means blocking else { if (current_timeout == 0) { @@ -305,14 +305,14 @@ NetSock::set_timeout(int msecs) ::setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*) &maxto, sizeof(maxto)); ::setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char*) &maxto, sizeof(maxto)); } - + // otherwise, set the timeout else { ::setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*) &msecs, sizeof(msecs)); ::setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char*) &msecs, sizeof(msecs)); } } - + current_timeout = msecs; return 1; } |