Documentation ¶
Overview ¶
This program is a combination of parts 2 and 3.
It listens on the host and port specified by the -listen flag. For each incoming connection, it launches a goroutine that reads and decodes JSON-encoded messages from the connection and prints them to standard output. It concurrently makes a connection to the host and port specified by the -dial flag, reads lines from standard input, and writes JSON-encoded messages to the network connection.
You can test it by running part3 in one terminal:
$ part3 -listen=localhost:8000
Running this program in another terminal:
$ part4 -listen=localhost:8001 -dial=localhost:8000
And running part2 in another terminal:
$ part2 -dial=localhost:8001
Lines typed in the second terminal should appear as JSON objects in the first terminal, and those typed at the third terminal should appear in the second.