diff options
author | Bert Belder <bertbelder@gmail.com> | 2010-11-25 05:03:39 +0100 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2010-12-20 23:51:10 +0100 |
commit | 51300f36d6d09b1f51c81514fff8644df0e79eee (patch) | |
tree | 87240e3ed9e0208612ff55276fb98137442648c1 /src/node_net.cc | |
parent | 6e522fb27bd7ebf0d0bb7c569e13b1d7e71ddf9e (diff) | |
download | node-new-51300f36d6d09b1f51c81514fff8644df0e79eee.tar.gz |
Make SetNonBlock and SetSockFlags work on FDs instead of sockets
However, don't use _get_osfhandle in Close()
Diffstat (limited to 'src/node_net.cc')
-rw-r--r-- | src/node_net.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/node_net.cc b/src/node_net.cc index 76453b68ef..bafae4be15 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -96,7 +96,7 @@ static inline bool SetCloseOnExec(int fd) { static inline bool SetNonBlock(int fd) { #ifdef __MINGW32__ unsigned long value = 1; - return (ioctlsocket(fd, FIONBIO, &value)); + return (ioctlsocket(_get_osfhandle(fd), FIONBIO, &value) == 0); #else // __POSIX__ return (fcntl(fd, F_SETFL, O_NONBLOCK) != -1); #endif @@ -106,7 +106,7 @@ static inline bool SetNonBlock(int fd) { static inline bool SetSockFlags(int fd) { #ifdef __MINGW32__ int flags = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)); + setsockopt(_get_osfhandle(fd), SOL_SOCKET, SO_REUSEADDR, (const char *)&flags, sizeof(flags)); return SetNonBlock(fd); #else // __POSIX__ int flags = 1; @@ -340,6 +340,7 @@ static Handle<Value> Close(const Arguments& args) { FD_ARG(args[0]) + // Windows: don't use _get_osfhandle here! if (0 > close(fd)) { return ThrowException(ErrnoException(errno, "close")); } |