MsetTypeOfService
Bun

method

tls.TLSSocket.setTypeOfService

tos: number
): this;

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.

@param tos

The TOS value to set (0-255).

@returns

The socket itself.