diff --git a/doc/api/net.md b/doc/api/net.md index 0bc2adbd455b8b..dc03e5b95e6729 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -1461,6 +1461,45 @@ If `timeout` is 0, then the existing idle timeout is disabled. The optional `callback` parameter will be added as a one-time listener for the [`'timeout'`][] event. +### `socket.getTypeOfService()` + + + +* Returns: {integer} The current TOS value. + +Returns the current Type of Service (TOS) field for IPv4 packets or Traffic +Class for IPv6 packets for this socket. + +`setTypeOfService()` may be called before the socket is connected; the value +will be cached and applied when the socket establishes a connection. +`getTypeOfService()` will return the currently set value even before connection. + +On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored, +and behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers +should verify platform-specific semantics. + +### `socket.setTypeOfService(tos)` + + + +* `tos` {integer} The TOS value to set (0-255). +* Returns: {net.Socket} The socket itself. + +Sets the Type of Service (TOS) field for IPv4 packets or Traffic Class for IPv6 +Packets sent from this socket. This can be used to prioritize network traffic. + +`setTypeOfService()` may be called before the socket is connected; the value +will be cached and applied when the socket establishes a connection. +`getTypeOfService()` will return the currently set value even before connection. + +On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored, +and behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers +should verify platform-specific semantics. + ### `socket.timeout`