August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, you are going to see an alternative implementation of a TCP server in Go. This time, the TCP server implements the Echo service, which basically returns to the client, the data that the client sent. The program is called otherTCPserver.go, and it will be presented in four parts.
The first part of otherTCPserver.go is as follows:
package main
import (
"fmt"
"net"
"os"
"strings"
)
The second portion of otherTCPserver.go contains the following Go code:
func main() { arguments := os.Args if len(arguments) == 1 { fmt.Println("Please provide a port number!") return } SERVER := "localhost" + ":" + arguments[1] s, err := net.ResolveTCPAddr("tcp", SERVER) if err != nil { fmt.Println(err) ...Read now
Unlock full access