As with the TCP server, the UDP server can be created with the help of the net package. With the use of the ListenPacket function, the PacketConn is created.
The PacketConn does not implement the Reader and Writer interface as the TCPConn. For reading the received packet, the ReadFrom method should be used. The ReadFrom method blocks until the packet is received. After this, the Addr of the client is returned (remember the UDP is not connection-based ). To respond to the client, the WriteTo method of PacketConn could be used; this consumes the message and the Addr, which is the client Addr, in this case.