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 traits that describe socket options, and the options that more than one kind of socket accepts.

Each protocol's option module, such as std.net.tcp.option, re-exports the shared options that its sockets accept.

comptime values​

ReuseAddress​

comptime ReuseAddress = FlagOption["ReuseAddress", constant[StringSpan("SOL_SOCKET"), linux=Int32(1), macos=Int32(65535)](), constant[StringSpan("SO_REUSEADDR"), linux=Int32(2), macos=Int32(4)]()]

Represents SO_REUSEADDR: whether the socket can bind a local address that connections from an earlier socket still hold.

A server that restarts needs it to bind its port again while connections from its last run are still closing.

ReusePort​

comptime ReusePort = FlagOption["ReusePort", constant[StringSpan("SOL_SOCKET"), linux=Int32(1), macos=Int32(65535)](), constant[StringSpan("SO_REUSEPORT"), linux=Int32(15), macos=Int32(512)]()]

Represents SO_REUSEPORT: whether other sockets can bind the same address and port.

Structs​

  • ​FlagOption: Represents a socket option that is either on or off.

Traits​