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).

FlagOption

struct FlagOption[name: StaticString, level: Int32, number: Int32]

Represents a socket option that is either on or off.

Each option of this kind is a comptime alias of this type, such as ReuseAddress.

Parameters​

  • ​name (StaticString): The option's name, such as "ReuseAddress".
  • ​level (Int32): The level the option belongs to, as passed to setsockopt.
  • ​number (Int32): The option's number within its level, which setsockopt takes as option_name.

Implemented traits​

AnyType, Deinitable, GettableSocketOption, Movable, SettableSocketOption, SocketOption

comptime members​

OptionType​

comptime OptionType = Bool

Whether the option is on.

Methods​

set_option​

static def set_option(socket: Socket, var option: Bool)

Turns the option on or off.

Args:

  • ​socket (Socket): The socket to set it on.
  • ​option (Bool): Whether to turn it on.

Raises:

If the option can't be set.

get_option​

static def get_option(socket: Socket) -> Bool

Returns whether the option is on.

Args:

  • ​socket (Socket): The socket to read it from.

Returns:

Bool: Whether it's on.

Raises:

If the option can't be read.