TCP program flow
A TCP client program must first know the TCP server's address. This is often input by a user. In the case of a web browser, the server address is either input directly by the user into the address bar, or is known from the user clicking on a link. The TCP client takes this address (for example, http://example.com) and uses the getaddrinfo() function to resolve it into a struct addrinfo structure. The client then creates a socket using a call to socket(). The client then establishes the new TCP connection by calling connect(). At this point, the client can freely exchange data using send() and recv().
A TCP server listens for connections at a particular port number on a particular interface. The program must first initialize ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access