October 2015
Beginner to intermediate
400 pages
14h 44m
English
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.
The net/http package we’ve been using since Chapter 1 is built on top of functions from the
net package.
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 ...