September 2017
Intermediate to advanced
466 pages
9h 33m
English
This section will develop a TCP server that implements the Echo service. The Echo service is usually implemented using the UDP protocol due to its simplicity, but it can also be implemented with TCP. The Echo service usually uses port number 7, but our implementation will use other port numbers:
$ grep echo /etc/services echo 7/tcp echo 7/udp
The TCPserver.go file will hold the Go code of this section and will be presented in six parts. For reasons of simplicity, each connection is handled inside the main() function without calling a separate function. However, this is not the recommended practice.
The first part contains the expected preamble:
package main import ( "bufio" "fmt" "net" "os" "strings" )
The ...
Read now
Unlock full access