Skip to content

Commit 24697c2

Browse files
committed
net: Add noDelay to net.Socket() options
Add the noDelay option to the net.Socket() options such that .setNoDelay() will be called when a socket is created
1 parent 844418c commit 24697c2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

doc/api/net.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ added: v0.3.4
417417
* `allowHalfOpen` {boolean} Indicates whether half-opened TCP connections
418418
are allowed. See [`net.createServer()`][] and the [`'end'`][] event
419419
for details. **Default:** `false`.
420+
* `noDelay` {boolean} A boolean with which to call [`socket.setNoDelay()`][]
421+
when a socket connection is established. This only applies when the
422+
underlying connection is a TCP socket.
420423
* `readable` {boolean} Allow reads on the socket when an `fd` is passed,
421424
otherwise ignored. **Default:** `false`.
422425
* `writable` {boolean} Allow writes on the socket when an `fd` is passed,
@@ -1262,6 +1265,7 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`.
12621265
[`socket.pause()`]: #net_socket_pause
12631266
[`socket.resume()`]: #net_socket_resume
12641267
[`socket.setEncoding()`]: #net_socket_setencoding_encoding
1268+
[`socket.setNoDelay()`]: #net_socket_setnodelay_nodelay
12651269
[`socket.setTimeout()`]: #net_socket_settimeout_timeout_callback
12661270
[`socket.setTimeout(timeout)`]: #net_socket_settimeout_timeout_callback
12671271
[half-closed]: https://tools.ietf.org/html/rfc1122

lib/net.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ function Socket(options) {
378378
this.server = null;
379379
this._server = null;
380380

381+
if (options.noDelay !== undefined) {
382+
this.setNoDelay(options.noDelay);
383+
}
384+
381385
// Used after `.destroy()`
382386
this[kBytesRead] = 0;
383387
this[kBytesWritten] = 0;

0 commit comments

Comments
 (0)