Sending and receiving UDP packets between two programs on the same computer

You can bind to a port multiple times using the ReuseAddress socket option.

UdpClient udpClient = new UdpClient();
udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

You’ll need to set the same option on the UDP server socket as well.

Leave a Comment