Timeout on connect()

Usually, when we call connect() on a TCP socket, connect() blocks until the connection is established.

The following diagram illustrates the TCP three-way handshake that establishes a typical TCP connection and how it relates to a standard, blocking connect() call:

The standard TCP three-way handshake consists of three parts. First, the Client sends a Synchronize (SYN) message to the Server. Then the Server responds with an SYN Message of its own, combined with an Acknowledged (ACK) message of the Client's SYN Message. The Client then responds with an acknowledgment of the Server's SYN Message. The connection is then open ...

Get Hands-On Network Programming with C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.