Target

public struct Target : Hashable

A struct that represents a network target. It consists of a hostname or an IP address and a port number.

  • The hostname or IP address of the target. The IP address can either be IPv4 or IPv6.

    Declaration

    Swift

    public let hostname: String
  • The port.

    Declaration

    Swift

    public let port: UInt16
  • Initialize a target with a given hostname and port.

    Declaration

    Swift

    public init?(withHostname hostname: String, andPort port: UInt16)

    Parameters

    hostname

    The hostname or IP address.

    port

    The port

    Return Value

    nil if hostname or port is invalid.

  • A string representation of the target.

    Declaration

    Swift

    public func formatted() -> String

    Return Value

    example.com:80 if the hostname is example.com and the port is 80.