TCP is a reliable transport protocol for transferring data between applications. It checks for errors, preserves delivery order, and retransmits lost data, trading extra overhead for reliability. section 3.1
A TCP server follows a straightforward socket setup:
- Create an IPv4 stream socket with socket.AF_INET and socket.SOCK_STREAM. section 3.1
- Bind it to a hostname and port, enable address reuse, and listen for clients. section 3.1
- Accept a connection, then use the resulting connection socket to communicate with the client. section 3.1
A local TCP server
A Python server binds to 127.0.0.1:8000, listens, accepts one client connection, and prints the client's address. The listening socket accepts connections; the returned connection socket communicates with the client. section 3.1
Figure 3.1 A client connects to our server socket. The server then creates a new socket to communicate with the client.
Shows the distinction between the listening server socket and the new socket created for client communication. section 3.1




