Enumerationswift-nio 2.72.0NIOCore
SocketAddress
Represent a socket address to which we may want to connect or bind.
SocketAddresses.swift:83enum SocketAddress
Cases
case v4(IPv4Address)
An IPv4
SocketAddress
.case v6(IPv6Address)
An IPv6
SocketAddress
.case unixDomainSocket(UnixSocketAddress)
An UNIX Domain
SocketAddress
.
See also
enum System
struct NIONetworkDevice
A representation of a single network device on a system.
class NIONetworkInterface
A representation of a single network interface on a system.
enum NIOBSDSocket
struct NIOIPProtocol
In the Internet Protocol version 4 (IPv4) [RFC791] there is a field called “Protocol” to identify the next level protocol. This is an 8 bit field. In Internet Protocol version 6 (IPv6) [RFC8200], this field is called the “Next Header” field.
Citizens in NIOCore
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
Types
struct IPv4Address
A single IPv4 address for
SocketAddress
.struct IPv6Address
A single IPv6 address for
SocketAddress
.struct UnixSocketAddress
A single Unix socket address for
SocketAddress
.
Type members
init(sockaddr_in
) Creates a new IPv4
SocketAddress
.init(sockaddr_un
) Creates a new Unix Domain Socket
SocketAddress
.init(sockaddr_in6
) Creates a new IPv6
SocketAddress
.init(sockaddr_in, host: String
) Creates a new IPv4
SocketAddress
.init(sockaddr_in6, host: String
) Creates a new IPv6
SocketAddress
.init(ipAddress: String, port: Int
) throws Create a new
SocketAddress
for an IP address in string form.init(packedIPAddress: ByteBuffer, port: Int
) throws Create a new
SocketAddress
for an IP address in ByteBuffer form.init(unixDomainSocketPath: String
) throws Creates a new UDS
SocketAddress
.static func makeAddressResolvingHost(String, port: Int
) throws -> SocketAddress Creates a new
SocketAddress
for the given host (which will be resolved) and port.static func == (lhs: SocketAddress, rhs: SocketAddress
) -> Bool
Instance members
var description: String
A human-readable description of this
SocketAddress
. Mostly useful for logging.var ipAddress: String?
Get the IP address as a string
var isMulticast: Bool
Whether this
SocketAddress
corresponds to a multicast address.var pathname: String?
Get the pathname of a UNIX domain socket as a string
var port: Int?
Get and set the port associated with the address, if defined. When setting to
nil
the port will default to0
for compatible sockets. The rationale for this is that bothnil
and0
can be interpreted as “no preference”. Setting a non-nil value for a unix domain socket is invalid and will result in a fatal error.var `protocol`: NIOBSDSocket.ProtocolFamily
Returns the protocol family as defined in
man 2 socket
of thisSocketAddress
.func hash(into: inout Hasher
) func withSockAddr<T>((UnsafePointer<sockaddr>, Int) throws -> T
) rethrows -> T Calls the given function with a pointer to a
sockaddr
structure and the associated size of that structure.
Show obsolete interfaces (1)
Hide obsolete interfaces
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.
Extension in Vapor
Instance members
var hostname: String?
Returns the hostname for this
SocketAddress
if one exists.