@@ -49,6 +49,7 @@ using v8::TryCatch;
49
49
using v8::Context;
50
50
using v8::Arguments;
51
51
using v8::Integer;
52
+ using v8::Undefined;
52
53
53
54
static Persistent<Function> tcpConstructor;
54
55
static Persistent<String> family_symbol;
@@ -96,6 +97,8 @@ void TCPWrap::Initialize(Handle<Object> target) {
96
97
NODE_SET_PROTOTYPE_METHOD (t, " connect6" , Connect6);
97
98
NODE_SET_PROTOTYPE_METHOD (t, " getsockname" , GetSockName);
98
99
NODE_SET_PROTOTYPE_METHOD (t, " getpeername" , GetPeerName);
100
+ NODE_SET_PROTOTYPE_METHOD (t, " setNoDelay" , SetNoDelay);
101
+ NODE_SET_PROTOTYPE_METHOD (t, " setKeepAlive" , SetKeepAlive);
99
102
100
103
tcpConstructor = Persistent<Function>::New (t->GetFunction ());
101
104
@@ -219,6 +222,35 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
219
222
}
220
223
221
224
225
+ Handle <Value> TCPWrap::SetNoDelay (const Arguments& args) {
226
+ HandleScope scope;
227
+
228
+ UNWRAP
229
+
230
+ int r = uv_tcp_nodelay (&wrap->handle_ , 1 );
231
+ if (r)
232
+ SetErrno (uv_last_error (uv_default_loop ()));
233
+
234
+ return Undefined ();
235
+ }
236
+
237
+
238
+ Handle <Value> TCPWrap::SetKeepAlive (const Arguments& args) {
239
+ HandleScope scope;
240
+
241
+ UNWRAP
242
+
243
+ int enable = args[0 ]->Int32Value ();
244
+ unsigned int delay = args[1 ]->Uint32Value ();
245
+
246
+ int r = uv_tcp_keepalive (&wrap->handle_ , enable, delay);
247
+ if (r)
248
+ SetErrno (uv_last_error (uv_default_loop ()));
249
+
250
+ return Undefined ();
251
+ }
252
+
253
+
222
254
Handle <Value> TCPWrap::Bind (const Arguments& args) {
223
255
HandleScope scope;
224
256
0 commit comments