IPAddress

public struct IPAddress

IPAddress represents an IP (v4 or v6) address.

  • Undocumented

    Declaration

    Swift

    public struct IPAddress
  • Creates an IPAddress by parsing the string which must be in 1.2.3.4 or ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff formats (IPv4 or IPv6).

    Declaration

    Swift

    public init?(parsing s: String)
  • Creates an IP address corresponding to the provided bytes. The number of bytes must match either an IPv4 or IPv6 address.

    Declaration

    Swift

    public init?(bytes: [UInt8])
  • Creates an IPv4 address. The four UInt8 arguments represent the 4 bytes of the address, matching the IPv4 display format.

    Declaration

    Swift

    public init(_ b0: UInt8, _ b1: UInt8, _ b2: UInt8, _ b3: UInt8)
  • Creates an IPv6 address. The UInt16 arguments can be passed as hexadecimal to match the IPv6 display format.

    Declaration

    Swift

    public init(_ bb0: UInt16, _ bb1: UInt16, _ bb2: UInt16, _ bb3: UInt16,
           _ bb4: UInt16, _ bb5: UInt16, _ bb6: UInt16, _ bb7: UInt16)
  • Indicates the address family (ip4 or ip6).

    Declaration

    Swift

    public var family: Family
  • The typical IPv4 loopback address.

    Declaration

    Swift

    public static let ip4Loopback = IPAddress(127, 0, 0, 1)
  • The IPv6 loopback address.

    Declaration

    Swift

    public static let ip6Loopback = IPAddress(0, 0, 0, 0, 0, 0, 0, 1)
  • Equatable implementation for IPAddress.

    Declaration

    Swift

    public static func ==(lhs: IPAddress, rhs: IPAddress) -> Bool