Skip to content
FutureBlitz

    Install

    Import std.net.address

    SocketAddress

    std.net.address

    struct

    Public Struct SocketAddress Implements Hashable, Comparable, Printable

    An IpAddress with a port: where a socket connects to or listens on. An IPv6 one can have a scope, its zone's index, for a link-local address, as in [fe80::1%3]:80.

    Examples

    Local server = SocketAddress.Parse("[::1]:8080")
    Expect(server?.Port == 8080 && server?.Family == IpFamily.V6)
    Expect("{SocketAddress(IpAddress.Loopback, 80)}" == "127.0.0.1:80")

    std/net/address.fb, line 273

    • Public ReadOnly Field Address: IpAddress field #

      Its address.

    • Public ReadOnly Field Port: UInt16 field #

      Its port.

    • Public ReadOnly Field ScopeId: UInt32 field #

      An IPv6 link-local address's scope, its zone's index, or 0 for none.

    • @PanicsAtCaller Public New(address: IpAddress, port: UInt16, scopeId: UInt32 = 0) constructor #

      The address at port, and for an IPv6 link-local one, the scopeId of its interface. Panics for a ScopeId on an IPv4 address, which has none.

    • Public Static Method Parse(text: String): SocketAddress? static method #

      The address text writes as ToString does: an IPv4 address and its port, as in 127.0.0.1:80, or an IPv6 one in brackets, with its scope's number after a %, as in [::1]:80 and [fe80::1%3]:80. Null for anything else, a scope's name like %eth0 too.

    • Public Property Family: IpFamily property #

      Its address's family.

    • Public Method ToString(): String method #

      The address and its port, as "127.0.0.1:8080" for IPv4, or "[::1]:8080" for IPv6, with "%" and its scope ID inside the brackets when it has one.

    • Operator <(a: SocketAddress, b: SocketAddress): Bool operator #

      Whether a comes before b: by their addresses, then their ports, then their scope IDs.

    Report an issue with this page or with FutureBlitz on GitHub.