liveBook · Manning

UDP

As explained in Rust in Action: Systems programming concepts and techniques

UDP is a connectionless transport protocol that sends independent datagrams without guaranteeing delivery, ordering, or duplication control.

UDP is a connectionless transport protocol that sends independent datagrams without guaranteeing delivery, ordering, or duplication control. Two-way communication requires each side to act as both client and server. section 8.11

DNS provides a practical UDP use case: a resolver sends a query to a DNS server, which returns an answer containing the requested IP address. DNS can also use TCP and TLS, but UDP is used for DNS requests. section 8.4.2

A small Rust resolver demonstrates the surrounding workflow:

  • Resolve the hostname into a domain-name representation, construct a DNS query, and request an IPv4 address. section 8.4.2
  • Use Rust's UdpSocket together with trust-dns to exchange and interpret the message. section 8.4.2

Resolve a hostname

Running `cargo run -q -- www.rustinaction.com` produces an IPv4 address such as `35.185.44.232`; the `-s` option selects another DNS server.

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Demonstrates UDP through DNS message construction and exchange, but treats only a small portion of the DNS protocol.
Examples
Uses a Rust command-line resolver, constructed DNS queries, public DNS providers, and hostname-to-IPv4 output.
What it assumes
Assumes basic Rust and networking familiarity while introducing DNS resolution, domain names, and IP addresses.
What you can do after
Build a small hostname resolver with Rust's UdpSocket and the trust-dns crate.
How it connects
Connects UDP with DNS, TCP, TLS, IP addresses, domain names, and Rust's UdpSocket.

Also explained in

Compare how 5 books explain UDP →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.