Initializerswift-nio 2.72.0NIOCore
init(_:host:)
Creates a new IPv6 SocketAddress
.
init(_ addr: sockaddr_in6, host: String)
Parameters
Other members in extension
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(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.