Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: 5b9d10224c
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (31 sloc) 1.03 kb
\begin{Exercise}[title={Echo server},difficulty=1]
\Question\label{ex:echo q1}
Write a simple echo server. Make it listen to TCP port number 8053 on localhost. It should
be able to read a line (up to the newline), echo back that line and then close the connection.
\Question\label{ex:echo q2}
Make the server concurrent so that every request is taken care of in a separate
A simple echo server might be:
\lstinputlisting[caption=A simple echo server]{ex-communication/src/echo.go}
When started you should see the following:
\pr \user{nc 8053}
\user{Go is *awesome*}
Go is *awesome*
To make the connection handling concurrent we \emph{only need to change one line} in our
echo server, the line:
if c, err := l.Accept(); err == nil { Echo(c) }
if c, err := l.Accept(); err == nil { go Echo(c) }
Jump to Line
Something went wrong with that request. Please try again.