September 2017
Intermediate to advanced
466 pages
9h 33m
English
Once again, we will implement TCPclient.go using some slightly different functions that are provided by the net Go standard package. The name of the new version will be TCPc.go and will be shown in four code segments.
The first part is the following:
package main import ( "fmt" "net" "os" )
The second code segment of the program is the following:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Please provide a server:port string!")
os.Exit(100)
}
CONNECT := arguments[1]
myMessage := "Hello from TCP client!\n"
This time, we will send a static message to the TCP server.
The third part of TCPc.go is the following:
tcpAddr, err := net.ResolveTCPAddr("tcp", CONNECT) if ...Read now
Unlock full access