std1.0.0-beta-7 SafeC docs

std :: sched::io_nb

Function std::tcp_connect_timeout

#include <std/sched/io_nb.h> source · definition

int tcp_connect_timeout(
    unsigned int addr_network_order,
    unsigned short port,
    int timeout_ms,
)

socket()+connect() that waits at most 'timeout_ms' (<= 0: no limit beyond the kernel's own SYN retries, ~2 minutes on Linux) for the TCP handshake: non-blocking connect(), poll()/select() for writability, then SO_ERROR. Returns a connected socket already switched back to blocking mode, or -1 with the socket closed and the error left in errno (BSD/Linux) or WSAGetLastError() (Windows): ETIMEDOUT/ WSAETIMEDOUT on timeout, otherwise the connect error itself (ECONNREFUSED, ENETUNREACH, ...).