Browse Source

Port socketerror

v0.7.4-release
Bert Belder 14 years ago
parent
commit
ad41e778b4
  1. 15
      src/node_net.cc

15
src/node_net.cc

@ -648,8 +648,6 @@ static Handle<Value> Accept(const Arguments& args) {
} }
#ifdef __POSIX__
static Handle<Value> SocketError(const Arguments& args) { static Handle<Value> SocketError(const Arguments& args) {
HandleScope scope; HandleScope scope;
@ -657,16 +655,23 @@ static Handle<Value> SocketError(const Arguments& args) {
int error; int error;
socklen_t len = sizeof(int); socklen_t len = sizeof(int);
#ifdef __POSIX__
int r = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len); int r = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
if (r < 0) { if (r < 0) {
return ThrowException(ErrnoException(errno, "getsockopt")); return ThrowException(ErrnoException(errno, "getsockopt"));
} }
#else // __MINGW32__
int r = getsockopt(_get_osfhandle(fd), SOL_SOCKET, SO_ERROR, (char*)&error, &len);
return scope.Close(Integer::New(error)); if (r < 0) {
return ThrowException(ErrnoException(WSAGetLastError(), "getsockopt"));
} }
#endif
#endif // __POSIX__ return scope.Close(Integer::New(error));
}
// var bytesRead = t.read(fd, buffer, offset, length); // var bytesRead = t.read(fd, buffer, offset, length);
@ -1505,8 +1510,8 @@ void InitNet(Handle<Object> target) {
NODE_SET_METHOD(target, "bind", Bind); NODE_SET_METHOD(target, "bind", Bind);
NODE_SET_METHOD(target, "listen", Listen); NODE_SET_METHOD(target, "listen", Listen);
NODE_SET_METHOD(target, "accept", Accept); NODE_SET_METHOD(target, "accept", Accept);
#ifdef __POSIX__
NODE_SET_METHOD(target, "socketError", SocketError); NODE_SET_METHOD(target, "socketError", SocketError);
#ifdef __POSIX__
NODE_SET_METHOD(target, "toRead", ToRead); NODE_SET_METHOD(target, "toRead", ToRead);
NODE_SET_METHOD(target, "setNoDelay", SetNoDelay); NODE_SET_METHOD(target, "setNoDelay", SetNoDelay);
NODE_SET_METHOD(target, "setBroadcast", SetBroadcast); NODE_SET_METHOD(target, "setBroadcast", SetBroadcast);

Loading…
Cancel
Save