Initializer
init(host:port:)
Memberwise initializer for the host and port pair.
init(host: String, port: Int)
Parameters
-
host
-
Host component. See host for accepted forms.
-
port
-
TCP port, typically 1–65535.
Discussion
Assigns both fields verbatim; no canonicalisation, no validation. Construct once, compare freely — the value is Hashable/Sendable and safely crosses concurrency domains.
Note
If you always mean loopback, prefer localhost(_:) to avoid repeating the literal "127.0.0.1" at call sites.
Important
Case and whitespace in host are preserved literally. HostPort(host: " localhost", port: 9050) is not equal to HostPort(host: "localhost", port: 9050).