diff options
author | Rusty Conover <rusty@conover.me> | 2020-01-27 22:16:11 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-02-01 13:15:44 +0300 |
commit | 0fe810168bef2a53e5ff6b2f7832e372f850e5f3 (patch) | |
tree | d166f00dad56a5f96a5c379f16b325e5cb801c63 /doc/api/net.md | |
parent | 22724894c99845755dfdafc2a87236fc311343f1 (diff) |
doc: clarify socket.setNoDelay() explanation
Change the description of socket.setNoDelay() to make it clear
that sockets have Nagle's algorithm enabled by default.
Better document the tradeoff of having the algorithm enabled.
Explain the behavior of the function based on the passed arguments.
PR-URL: https://github.com/nodejs/node/pull/31541
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/net.md')
-rw-r--r-- | doc/api/net.md | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/doc/api/net.md b/doc/api/net.md index d04e7eff078..bb5a55e0e48 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -879,9 +879,16 @@ added: v0.1.90 * `noDelay` {boolean} **Default:** `true` * Returns: {net.Socket} The socket itself. -Disables the Nagle algorithm. By default TCP connections use the Nagle -algorithm, they buffer data before sending it off. Setting `true` for -`noDelay` will immediately fire off data each time `socket.write()` is called. +Enable/disable the use of Nagle's algorithm. + +When a TCP connection is created, it will have Nagle's algorithm enabled. + +Nagle's algorithm delays data before it is sent via the network. It attempts +to optimize throughput at the expense of latency. + +Passing `true` for `noDelay` or not passing an argument will disable Nagle's +algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's +algorithm. ### `socket.setTimeout(timeout[, callback])` <!-- YAML |