ConnectedSocket.connect

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

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.

  1. ConnectedSocket connect(SockAddr sa, Timeout timeout, bool nodelay)
  2. ConnectedSocket connect(SA sa, Timeout timeout, bool nodelay)
    struct ConnectedSocket
    static @safe @nogc
    connect
    (
    SA
    )
    (
    SA sa
    ,,
    bool nodelay = true
    )
    if (
    is(typeof(SockAddr(sa)) == SockAddr)
    )

Parameters

sa SA

a socket address for the server to connect to (either SockAddr or SockAddr* where * is IPv4, IPv6 or Unix.)

timeout Timeout

the timeout for the connection. Throws TimeoutExpired if the timeout expires

nodelay bool

by default, Nagle algorithm is disabled for TCP connections. Setting this parameter to false reverts to the system-wide configuration.

Return Value

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.

Meta