Add example of robust socket echo server
The net package has some good examples for writing socket servers, but it doesn't provide a full example for a robust echo server that reads all data from clients around errors and EOFs.
io.Reader's docs say:
When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.
This is something that's not hard to demonstrate with fairly little amount of code, and a robust socket echo server would make a good example.
Hi, I have prepared an answer to the problem, raised in the link below. Hope you enjoy it :) 316
At a glance the linked example looks like it's headed in the right direction. An example would need to be edited for concision, style, and have commentary in line with the rest of the site, and be introduced as a PR against this repo. I don't personally have time to work on that right now, but if someone else does feel free to go for it!