RVS_IPAddress

public protocol RVS_IPAddress

This protocol is an abstract base for IP addresses. When we parse a String as an IP address, it will return a specific implementation of this.

When we say “valid,” we don’t mean the address resolves to anything; just that it is syntactically correct.

This file is the only one that you need for your implementation. Simply copy it wherever you want in your project, and add it to your chosen target.

  • isEmpty Default implementation

    Default Implementation

    Declaration

    Swift

    var isEmpty: Bool { get }

    Return Value

    true, if the IP address is invalid (all 0’s).

  • isV6 Default implementation

    Default Implementation

    Declaration

    Swift

    var isV6: Bool { get }

    Return Value

    true, if this is a valid IPV6 address.

  • isValidAddress Default implementation

    Default Implementation

    Declaration

    Swift

    var isValidAddress: Bool { get }

    Return Value

    true, if this is a valid IPV6 or IPV4 address.

  • address Default implementation

    Default Implementation

    Declaration

    Swift

    var address: String { get }

    Return Value

    just the address portion of an address/port pair, as a syntactically correct String.

  • Declaration

    Swift

    var addressAndPort: String { get }

    Return Value

    both the address, and the port, as a syntactically correct String.

  • Declaration

    Swift

    var port: Int { get set }

    Return Value

    The TCP port, as an unsigned integer.

  • Declaration

    Swift

    var addressArray: [Int] { get set }

    Return Value

    The actual IP address, as an Array of Int, with each element being one of the displayed elements.

  • description Default implementation

    Default Implementation

    Declaration

    Swift

    var description: String { get }

    Return Value

    The address and port, as a String.