Port socketerror
This commit is contained in:
parent
dd3308851d
commit
ad41e778b4
@ -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,17 +655,24 @@ 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);
|
||||||
|
|
||||||
|
if (r < 0) {
|
||||||
|
return ThrowException(ErrnoException(WSAGetLastError(), "getsockopt"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return scope.Close(Integer::New(error));
|
return scope.Close(Integer::New(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __POSIX__
|
|
||||||
|
|
||||||
|
|
||||||
// var bytesRead = t.read(fd, buffer, offset, length);
|
// var bytesRead = t.read(fd, buffer, offset, length);
|
||||||
// returns null on EAGAIN or EINTR, raises an exception on all other errors
|
// returns null on EAGAIN or EINTR, raises an exception on all other errors
|
||||||
@ -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…
x
Reference in New Issue
Block a user