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

SocketAddrV6

struct SocketAddrV6

Represents an IPv6 socket address.

Implemented traits​

AnyType, Copyable, Deinitable, Equatable, Hashable, ImplicitlyCopyable, Movable, Writable

Methods​

__init__​

def __init__(out self, ip: Ipv6Addr, port: UInt16, flowinfo: UInt32 = UInt32(0), scope_id: UInt32 = UInt32(0))

Constructs a socket address from an IPv6 address and a port.

Args:

  • ​ip (Ipv6Addr): The IPv6 address.
  • ​port (UInt16): The port number in host byte order.
  • ​flowinfo (UInt32): The flow information, which combines the flow label and the traffic class. See flowinfo().
  • ​scope_id (UInt32): The scope ID.

ip​

def ip(self) -> Ipv6Addr

Returns the IPv6 address.

Returns:

Ipv6Addr: The IPv6 address.

port​

def port(self) -> UInt16

Returns the port number.

Returns:

UInt16: The port number in host byte order.

flowinfo​

def flowinfo(self) -> UInt32

Returns the flow information.

This is the sin6_flowinfo field of C's struct sockaddr_in6, from RFC 2553, section 3.3. It isn't just the flow label: its 32 bits combine the 20-bit flow label and the 8-bit traffic class, which RFC 8200 defines in sections 6 and 7.

Returns:

UInt32: The flow information.

scope_id​

def scope_id(self) -> UInt32

Returns the scope ID.

Returns:

UInt32: The scope ID.

write_to​

def write_to(self, mut writer: T)

Writes the socket address as [address]:port, such as [::1]:8080.

A nonzero scope ID follows the address after a %, such as [fe80::1%2]:8080. The flow information isn't written.

Args:

  • ​writer (T): The writer to write to.