This section will also develop an Echo server. However, this time the Echo server will use the UDP protocol. The name of the program will be UDPserver.go and will be presented to you in five parts.
The first part contains the expected preamble:
package main import ( "fmt" "net" "os" "strings" )
The second part is the following:
func main() { arguments := os.Args if len(arguments) == 1 { fmt.Println("Please provide a port number!") os.Exit(100) } PORT := ":" + arguments[1]
The third part of UDPserver.go is the following:
s, err := net.ResolveUDPAddr("udp", PORT) if err != nil { fmt.Println(err) os.Exit(100) } connection, err := net.ListenUDP("udp", s) if err != nil { ...