Skip to content

Commit 2d42b03

Browse files
haramjaduh95
authored andcommitted
doc: clarify sub-1000ms behavior in socket.setKeepAlive
The current documentation states that `initialDelay` and `interval` are divided by 1000 and rounded down, but does not explicitly mention that values less than 1000ms will result in 0 seconds. This can lead to confusion when users pass values like 400ms expecting sub-second keepalive delays. Add a concrete example showing that 400ms rounds down to 0 seconds. Refs: #57712 Signed-off-by: haramjeong <04harams77@gmail.com> PR-URL: #65869 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
1 parent 301d896 commit 2d42b03

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎doc/api/net.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,9 @@ corresponding system default unchanged.
16281628

16291629
`initialDelay` and `interval` are specified in milliseconds but the
16301630
underlying socket options are configured in whole seconds; the values are
1631-
divided by `1000` and rounded down before being applied.
1631+
divided by `1000` and rounded down before being applied. For example,
1632+
setting `initialDelay` to `400` will result in a `TCP_KEEPIDLE` of `0`
1633+
seconds (since `400 / 1000` rounds down to `0`).
16321634

16331635
Enabling the keep-alive functionality will set the following socket options:
16341636

0 commit comments

Comments
 (0)