From 9cae638de6dc8dd9779c450201df8c102247a242 Mon Sep 17 00:00:00 2001 From: kai-xlr <62360539+kai-xlr@users.noreply.github.com> Date: Wed, 15 Jul 2026 13:05:27 -0400 Subject: [PATCH] examples: add UDP binding to all interfaces docs (#8283) Closes #6737 --- examples/echo-udp.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/echo-udp.rs b/examples/echo-udp.rs index 82fb80a48..1fdb79b17 100644 --- a/examples/echo-udp.rs +++ b/examples/echo-udp.rs @@ -9,6 +9,28 @@ //! cargo run --example connect-udp 127.0.0.1:8080 //! //! Each line you type in to the `connect-udp` terminal should be echo'd back to you! +//! +//! # Binding to all interfaces +//! +//! By default this example binds to `127.0.0.1` so it is only reachable +//! from the local machine. +//! +//! To listen on all interfaces instead: +//! +//! ```sh +//! cargo run --example echo-udp -- 0.0.0.0:8080 +//! ``` +//! +//! Binding to `0.0.0.0` exposes the server on all network interfaces. +//! Only do this in trusted network environments. +//! +//! On multi-homed systems, a UDP socket bound to a wildcard address +//! (`0.0.0.0` or `::`) cannot always send replies from the same local IP +//! that received the packet. Replies may therefore originate from a +//! different address than the client targeted. See [this Cloudflare blog +//! post][udp-blog] for more details. +//! +//! [udp-blog]: https://blog.cloudflare.com/everything-you-ever-wanted-to-know-about-udp-sockets-but-were-afraid-to-ask-part-1 #![warn(rust_2018_idioms)]