TCP Echo Server is a simple echo server written in Golang that works plainly over the TCP protocol. The server listens to connection requests, prepends a preconfigured prefix to the data it receives from a client and writes it back on the connection.
To start the TCP Echo Server locally, simply run the following command.
$ go run -v main.go 9000 hello
command-line-arguments
listening on [::]:9000, prefix: hello
To run the TCP Echo Server container, simply execute the following command.
$ docker run -p 9000:9000 venilnoronha/tcp-echo-server:latest
listening on [::]:9000, prefix: hello
To test the TCP Echo Server, run the following command.
$ echo world | nc localhost 9000
hello world
To run the unit test, execute the following command.
$ go test -v ./...
=== RUN TestTcpEchoServer
listening on [::]:9000, prefix: hello
request: world
response: hello world
--- PASS: TestTcpEchoServer (2.01s)
PASS
ok github.com/venilnoronha/tcp-echo-server 2.015s
The TCP Echo Server project is distributed under the BSD-style license found in the LICENSE file.