liveBook · Manning

TCP

As explained in Python Concurrency with asyncio

TCP is a reliable connection-oriented transport protocol that delivers an ordered byte stream between applications and retransmits lost data.

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.
03-01

Shows the distinction between the listening server socket and the new socket created for client communication. section 3.1

How Python Concurrency with asyncio covers it

How deep it goes
Explains reliability and socket setup through a runnable server, including binding, listening, and accepting connections.
Examples
Uses a Python server at 127.0.0.1:8000 that listens for and accepts a client connection.
What you can do after
Operate/configure a TCP server socket that binds locally, listens, accepts a connection, and identifies the client.
How it connects
Connects TCP with sockets, client-server communication, IPv4 addresses, and UDP as a lower-overhead contrast.

Also explained in

Compare how 5 books explain TCP →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python Concurrency with asyncio. The section links point to the parts of the book it draws on.