Type Method
connect(to:loop:)
Connects to a remote SocketAddress.
static func connect(to address: SocketAddress, loop: EventLoop = .shared) async throws -> Socket
Parameters
-
address
-
A pre-built endpoint from SocketAddress.
-
loop
-
The event loop to drive. Defaults to shared.
Return Value
A connected Socket.
Mentioned In
Discussion
Creates a fresh non-blocking TCP socket, calls connect(2), and (for EINPROGRESS) registers an EV_WRITE event to resume the continuation when the kernel completes the handshake.
Throws
SocketError.socketCreationFailed(_:) if socket(2) fails; SocketError.connectionFailed(_:) if connect(2) fails with anything other than EINPROGRESS.