Skip to content

Commit 356e505

Browse files
rustyconovercodebytere
authored andcommitted
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: #31541 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4e40c77 commit 356e505

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

doc/api/net.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,16 @@ added: v0.1.90
879879
* `noDelay` {boolean} **Default:** `true`
880880
* Returns: {net.Socket} The socket itself.
881881

882-
Disables the Nagle algorithm. By default TCP connections use the Nagle
883-
algorithm, they buffer data before sending it off. Setting `true` for
884-
`noDelay` will immediately fire off data each time `socket.write()` is called.
882+
Enable/disable the use of Nagle's algorithm.
883+
884+
When a TCP connection is created, it will have Nagle's algorithm enabled.
885+
886+
Nagle's algorithm delays data before it is sent via the network. It attempts
887+
to optimize throughput at the expense of latency.
888+
889+
Passing `true` for `noDelay` or not passing an argument will disable Nagle's
890+
algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
891+
algorithm.
885892

886893
### `socket.setTimeout(timeout[, callback])`
887894
<!-- YAML

0 commit comments

Comments
 (0)