Networking with inetd

On Unix-like systems, such as Linux or macOS, a service called inetd can be used to turn console-only applications into networked ones. You can configure inetd (with /etc/inetd.conf) with your program's location, port number, protocol (TCP or UDP), and the user you want it to run as. inetd will then listen for connections on your desired port. After an incoming connection is accepted by inetd, it will start your program and redirect all socket input/output through stdin and stdout.

Using inetd, we could have time_console.c behave like time_server.c with very minimal changes. We would only need to add in an extra printf() function with the HTTP response header, read from stdin, and configure inetd.

You may be able to use inetd on Windows through Cygwin or the Windows Subsystem for Linux.