liveBook · Manning

UDP

As explained in Fast Python: High performance techniques for large datasets

UDP (User Datagram Protocol) is a connectionless transport-layer protocol that sends datagrams without guaranteeing delivery, ordering, or duplicate suppression.

UDP is a connectionless transport protocol that sends packets without guaranteeing delivery, ordering, or duplicate suppression. Its lower overhead can improve performance when extra reliability is unnecessary, especially on reliable local networks. section 1.2.2 section 6.4.2

Assess these trade-offs before replacing HTTPS over TCP with UDP:

  • Accept possible packet loss between client and server. section 6.4.2
  • Expect packets to arrive out of order or be routed incorrectly. section 6.4.2
  • Recognize that an unencrypted channel permits eavesdropping and data modification. section 6.4.2
  • Prefer the trade-off when network reliability and latency requirements outweigh transport-level reliability. section 1.2.2 section 6.4.2

A Python UDP client

Create a datagram socket with socket.socket(socket.AF_INET, socket.SOCK_DGRAM), send serialized requests with sendto(), and receive responses with recv(). A pastebin-style client can encode store and retrieve commands with msgpack, send them to 127.0.0.1:54321, and exchange text identifiers and contents. section 6.4.2

Figure 1.3 API calls via the network stack. Understanding the alternatives available for network communication can dramatically increase the speed of internet-based applications.

Use the network-stack diagram to compare UDP with TCP, HTTP, HTTPS, IP, and lower network layers when selecting a communication path. section 1.2.2

How Fast Python: High performance techniques for large datasets covers it

How deep it goes
Explains datagram semantics, socket construction, message exchange, and security assumptions, but defers reliability handling.
Examples
Demonstrates a Python pastebin client using localhost, port 54321, msgpack commands, and sendto/recv operations.
What it assumes
Assumes familiarity with network layers and Python sockets while explaining UDP’s connectionless behavior from its contrast with TCP.
What you can do after
Operate/configure a Python UDP endpoint and judge whether its loss, ordering, encryption, and overhead trade-offs fit a networked application.
How it connects
Contrasts UDP with TCP and relates it to HTTPS, HTTP, JSON, IP, DNS, DHCP, sockets, and msgpack.

Also explained in

Compare how 5 books explain UDP →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast Python: High performance techniques for large datasets. The section links point to the parts of the book it draws on.