Networking is a natural domain in which to use concurrency since
servers typically handle many connections from their clients at once,
each client being essentially independent of the others.
In this section, we’ll introduce the
net package, which
provides the components for building networked client and server
programs that communicate over TCP, UDP, or Unix domain sockets.
net/http package we’ve been using since Chapter 1 is built on top of functions from the
Our first example is a sequential clock server that writes the current time to the client once per second:
// Clock1 is a TCP server that periodically writes the time. package ...