Exemplo n.º 1
0
func main() {
	if len(os.Args) != 2 {
		fmt.Fprintf(os.Stderr, "Please specify the port to listen: ")
		os.Exit(1)
	}

	port, err := strconv.Atoi(os.Args[1])
	udp.CheckError(err)
	udp.StartUdpServer(port)
}
Exemplo n.º 2
0
func main() {
	if len(os.Args) != 3 {
		fmt.Fprintf(os.Stderr, "Please specify the destination ip and port. ")
		os.Exit(1)
	}

	address := os.Args[1]
	port, err := strconv.Atoi(os.Args[2])
	udp.CheckError(err)

	message_id := udp.SendMessage(address, port, "This is the message text", 42)
	fmt.Println("Sent a message with id: " + message_id)
}