From 9f258a4a83d992e7f7ca4a998515661638436e81 Mon Sep 17 00:00:00 2001 From: Rusty Conover Date: Mon, 27 Jan 2020 14:16:11 -0500 Subject: [PATCH 1/5] docs: Reword socket.setNoDelay() 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. --- doc/api/net.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index d04e7eff0789a7..b3a0820dc55f6a 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 Nagle algorithm. + +TCP connections when they are created have the Nagle algorithm enabled. + +The Nagle algorithm delays data before it is sent via the network. It attempts +to optimize throughput at the expense of latency. + +Setting `true` for `noDelay` or not passing an argument will disable the Nagle +algorithm for the socket. Setting `false` for `noDelay` will enable the Nagle +algorithm. ### `socket.setTimeout(timeout[, callback])`