Skip to content

Commit

Permalink
net: Add noDelay to net.Socket() options
Browse files Browse the repository at this point in the history
Add the noDelay option to the net.Socket() options such that
.setNoDelay() will be called when a socket is created
  • Loading branch information
rustyconover committed Feb 26, 2020
1 parent 844418c commit 24697c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ added: v0.3.4
* `allowHalfOpen` {boolean} Indicates whether half-opened TCP connections
are allowed. See [`net.createServer()`][] and the [`'end'`][] event
for details. **Default:** `false`.
* `noDelay` {boolean} A boolean with which to call [`socket.setNoDelay()`][]
when a socket connection is established. This only applies when the
underlying connection is a TCP socket.
* `readable` {boolean} Allow reads on the socket when an `fd` is passed,
otherwise ignored. **Default:** `false`.
* `writable` {boolean} Allow writes on the socket when an `fd` is passed,
Expand Down Expand Up @@ -1262,6 +1265,7 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`.
[`socket.pause()`]: #net_socket_pause
[`socket.resume()`]: #net_socket_resume
[`socket.setEncoding()`]: #net_socket_setencoding_encoding
[`socket.setNoDelay()`]: #net_socket_setnodelay_nodelay
[`socket.setTimeout()`]: #net_socket_settimeout_timeout_callback
[`socket.setTimeout(timeout)`]: #net_socket_settimeout_timeout_callback
[half-closed]: https://tools.ietf.org/html/rfc1122
Expand Down
4 changes: 4 additions & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ function Socket(options) {
this.server = null;
this._server = null;

if (options.noDelay !== undefined) {
this.setNoDelay(options.noDelay);
}

// Used after `.destroy()`
this[kBytesRead] = 0;
this[kBytesWritten] = 0;
Expand Down

0 comments on commit 24697c2

Please sign in to comment.