|
@ -21,7 +21,7 @@ |
|
|
|
|
|
|
|
|
#include <node.h> |
|
|
#include <node.h> |
|
|
#include <node_buffer.h> |
|
|
#include <node_buffer.h> |
|
|
#include <node_isolate.h> |
|
|
#include <node_vars.h> |
|
|
#include <req_wrap.h> |
|
|
#include <req_wrap.h> |
|
|
#include <handle_wrap.h> |
|
|
#include <handle_wrap.h> |
|
|
#include <stream_wrap.h> |
|
|
#include <stream_wrap.h> |
|
@ -155,7 +155,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) { |
|
|
|
|
|
|
|
|
TCPWrap::TCPWrap(Handle<Object> object) |
|
|
TCPWrap::TCPWrap(Handle<Object> object) |
|
|
: StreamWrap(object, (uv_stream_t*) &handle_) { |
|
|
: StreamWrap(object, (uv_stream_t*) &handle_) { |
|
|
int r = uv_tcp_init(NODE_LOOP(), &handle_); |
|
|
int r = uv_tcp_init(Loop(), &handle_); |
|
|
assert(r == 0); // How do we proxy this error up to javascript?
|
|
|
assert(r == 0); // How do we proxy this error up to javascript?
|
|
|
// Suggestion: uv_tcp_init() returns void.
|
|
|
// Suggestion: uv_tcp_init() returns void.
|
|
|
UpdateWriteQueueSize(); |
|
|
UpdateWriteQueueSize(); |
|
@ -183,7 +183,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) { |
|
|
|
|
|
|
|
|
Local<Object> sockname = Object::New(); |
|
|
Local<Object> sockname = Object::New(); |
|
|
if (r != 0) { |
|
|
if (r != 0) { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
} else { |
|
|
} else { |
|
|
family = address.ss_family; |
|
|
family = address.ss_family; |
|
|
|
|
|
|
|
@ -225,7 +225,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) { |
|
|
|
|
|
|
|
|
Local<Object> sockname = Object::New(); |
|
|
Local<Object> sockname = Object::New(); |
|
|
if (r != 0) { |
|
|
if (r != 0) { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
} else { |
|
|
} else { |
|
|
family = address.ss_family; |
|
|
family = address.ss_family; |
|
|
|
|
|
|
|
@ -258,7 +258,7 @@ Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) { |
|
|
|
|
|
|
|
|
int r = uv_tcp_nodelay(&wrap->handle_, 1); |
|
|
int r = uv_tcp_nodelay(&wrap->handle_, 1); |
|
|
if (r) |
|
|
if (r) |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return Undefined(); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
@ -274,7 +274,7 @@ Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) { |
|
|
|
|
|
|
|
|
int r = uv_tcp_keepalive(&wrap->handle_, enable, delay); |
|
|
int r = uv_tcp_keepalive(&wrap->handle_, enable, delay); |
|
|
if (r) |
|
|
if (r) |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return Undefined(); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
@ -290,7 +290,7 @@ Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) { |
|
|
|
|
|
|
|
|
int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0); |
|
|
int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0); |
|
|
if (r) |
|
|
if (r) |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return Undefined(); |
|
|
return Undefined(); |
|
|
} |
|
|
} |
|
@ -309,7 +309,7 @@ Handle<Value> TCPWrap::Bind(const Arguments& args) { |
|
|
int r = uv_tcp_bind(&wrap->handle_, address); |
|
|
int r = uv_tcp_bind(&wrap->handle_, address); |
|
|
|
|
|
|
|
|
// Error starting the tcp.
|
|
|
// Error starting the tcp.
|
|
|
if (r) SetErrno(uv_last_error(NODE_LOOP())); |
|
|
if (r) SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(r)); |
|
|
return scope.Close(Integer::New(r)); |
|
|
} |
|
|
} |
|
@ -327,7 +327,7 @@ Handle<Value> TCPWrap::Bind6(const Arguments& args) { |
|
|
int r = uv_tcp_bind6(&wrap->handle_, address); |
|
|
int r = uv_tcp_bind6(&wrap->handle_, address); |
|
|
|
|
|
|
|
|
// Error starting the tcp.
|
|
|
// Error starting the tcp.
|
|
|
if (r) SetErrno(uv_last_error(NODE_LOOP())); |
|
|
if (r) SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(r)); |
|
|
return scope.Close(Integer::New(r)); |
|
|
} |
|
|
} |
|
@ -343,7 +343,7 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) { |
|
|
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); |
|
|
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); |
|
|
|
|
|
|
|
|
// Error starting the tcp.
|
|
|
// Error starting the tcp.
|
|
|
if (r) SetErrno(uv_last_error(NODE_LOOP())); |
|
|
if (r) SetErrno(uv_last_error(Loop())); |
|
|
|
|
|
|
|
|
return scope.Close(Integer::New(r)); |
|
|
return scope.Close(Integer::New(r)); |
|
|
} |
|
|
} |
|
@ -378,7 +378,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) { |
|
|
// Successful accept. Call the onconnection callback in JavaScript land.
|
|
|
// Successful accept. Call the onconnection callback in JavaScript land.
|
|
|
argv[0] = client_obj; |
|
|
argv[0] = client_obj; |
|
|
} else { |
|
|
} else { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
argv[0] = v8::Null(); |
|
|
argv[0] = v8::Null(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -397,7 +397,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) { |
|
|
assert(wrap->object_.IsEmpty() == false); |
|
|
assert(wrap->object_.IsEmpty() == false); |
|
|
|
|
|
|
|
|
if (status) { |
|
|
if (status) { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Local<Value> argv[3] = { |
|
|
Local<Value> argv[3] = { |
|
@ -433,7 +433,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) { |
|
|
req_wrap->Dispatched(); |
|
|
req_wrap->Dispatched(); |
|
|
|
|
|
|
|
|
if (r) { |
|
|
if (r) { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
delete req_wrap; |
|
|
delete req_wrap; |
|
|
return scope.Close(v8::Null()); |
|
|
return scope.Close(v8::Null()); |
|
|
} else { |
|
|
} else { |
|
@ -460,7 +460,7 @@ Handle<Value> TCPWrap::Connect6(const Arguments& args) { |
|
|
req_wrap->Dispatched(); |
|
|
req_wrap->Dispatched(); |
|
|
|
|
|
|
|
|
if (r) { |
|
|
if (r) { |
|
|
SetErrno(uv_last_error(NODE_LOOP())); |
|
|
SetErrno(uv_last_error(Loop())); |
|
|
delete req_wrap; |
|
|
delete req_wrap; |
|
|
return scope.Close(v8::Null()); |
|
|
return scope.Close(v8::Null()); |
|
|
} else { |
|
|
} else { |
|
|