Function ConnectedSocket.connect

Create a stream socket and connect, as client, to the address supplied

static ConnectedSocket connect (
  SockAddr sa,
  Timeout timeout = Timeout(TscTimePoint(9223372036854775807L)),
  bool nodelay = true
) @nogc @safe;

ConnectedSocket connect(SA) (
  SA sa,
  Timeout timeout = Timeout.infinite,
  bool nodelay = true
) @nogc @safe
if (is(typeof(SockAddr(sa)) == SockAddr));

This creates a TCP socket (or equivalent for the address family). It connects it to the designated server specified in sa, and waits, through the reactor, for the connection to be established.

Parameters

NameDescription
sa a socket address for the server to connect to (either SockAddr or SockAddr* where * is IPv4, IPv6 or Unix.)
timeout the timeout for the connection. Throws TimeoutExpired if the timeout expires
nodelay by default, Nagle algorithm is disabled for TCP connections. Setting this parameter to false reverts to the system-wide configuration.

Returns

Returns the connected socket.

Throws

TimeoutExpired if the timeout expires

ErrnoException if the connection fails (e.g. - ECONNREFUSED if connecting to a non-listening port). Also throws this if one of the system calls fails.

Anything else: May throw any exception injected using throwInFiber.