The TCP server that is going to be developed in this section will return the current date and time to the client in a single network packet. In practice, this means that after accepting a client connection, the server will get the time and date from the UNIX system and send that data back to the client.
The name of the utility is TCPserver.go, and it will be presented in four parts.
The first part of TCPserver.go is as follows:
package main import ( "bufio" "fmt" "net" "os" "strings" "time" )
The second code portion of TCPserver.go contains the following Go code:
func main() { arguments := os.Args if len(arguments) == 1 { fmt.Println("Please provide port number") return } PORT := ":" + arguments[1] l, err ...