Networking in C · beginner · ~6 min
Understand this course's safety policy for networking exercises, and learn how to enforce it directly in your code.
Every networking exercise in this course is localhost-only. Localhost means your own machine, reachable at the address 127.0.0.1 (also called the loopback address). Traffic to this address never leaves your computer.
In practice, that means:
INADDR_LOOPBACK (127.0.0.1), never INADDR_ANY.INADDR_ANY would listen on every network interface, including ones reachable from outside.127.0.0.1, never to an external host.--network=none, so even an exercise that tried to reach the public internet would simply fail with ENETUNREACH ("network unreachable").You lose nothing technically. You can practice every concept — the handshake, message framing, server design, error handling — without ever generating a packet that leaves your machine. The kernel's loopback interface handles all of it internally.
Legal and ethical reasons. Scanning, connecting to, or sending traffic to other people's hosts is not something this course teaches or condones. A defensive understanding of how servers work is enough.
Reproducibility. Localhost behaves the same everywhere: every machine, every CI runner, every Docker container.
If your own work ever genuinely requires testing against a remote service, do it on a machine you own, against a service you own. That is outside the scope of this curriculum.
/* GOOD — localhost only. */
a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
INADDR_ANY on a networked machine. Suddenly your "lab" server is reachable from every client on the same WiFi, not just from your own machine.INADDR_LOOPBACK, connect to 127.0.0.1.--network=none as a backstop, so off-machine traffic fails with ENETUNREACH.