September 2017
Intermediate to advanced
466 pages
9h 33m
English
In this subsection, we will develop the functionality of TCPserver.go using some slightly different functions. The name of the new TCP server will be TCPs.go and will be presented in four parts.
The first part of TCPs.go is the following:
package main import ( "fmt" "net" "os" )
The second part of the TCP server is the following:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide a port number!")
os.Exit(100)
}
SERVER := "localhost" + ":" + arguments[1]
So far, there are no differences from the code of TCPserver.go.
The differences start in the third part of TCPs.go, which is the following:
s, err := net.ResolveTCPAddr("tcp", SERVER) if err != nil { fmt.Println(err) ...Read now
Unlock full access