IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

option

Provides the options that TCP sockets accept.

This includes the options from std.net.option that other kinds of socket accept too, such as ReuseAddress.

comptime values​

KeepAlive​

comptime KeepAlive = FlagOption["KeepAlive", constant[StringSpan("SOL_SOCKET"), linux=Int32(1), macos=Int32(65535)](), constant[StringSpan("SO_KEEPALIVE"), linux=Int32(9), macos=Int32(8)]()]

Represents SO_KEEPALIVE: whether an idle connection sends probes to check that the peer is still there.

NoDelay​

comptime NoDelay = FlagOption["NoDelay", Int32(6), Int32(1)]

Represents TCP_NODELAY: whether small writes are sent right away instead of being batched.

By default, TCP holds back a small write until the data sent before it is acknowledged, so that it can combine small writes into fewer packets. Turning this on sends each write right away, which lowers latency for small messages, such as requests and replies, at the cost of sending more packets.