See Also: UdpClient Members
The System.Net.Sockets.UdpClient class provides simple methods for sending and receiving connectionless UDP datagrams in blocking synchronous mode. Because UDP is a connectionless transport protocol, you do not need to establish a remote host connection prior to sending and receiving data. You do, however, have the option of establishing a default remote host in one of the following two ways:
Create an instance of the System.Net.Sockets.UdpClient class using the remote host name and port number as parameters.
Create an instance of the System.Net.Sockets.UdpClient class and then call the UdpClient.Connect(string, int) method.
You can use any of the send methods provided in the System.Net.Sockets.UdpClient to send data to a remote device. Use the UdpClient.Receive(System.Net.IPEndPoint@) method to receive data from remote hosts.
Do not call UdpClient.Send(Byte[], int, System.Net.IPEndPoint) using a host name or System.Net.IPEndPoint if you have already specified a default remote host. If you do, System.Net.Sockets.UdpClient will throw an exception.
System.Net.Sockets.UdpClient methods also allow you to send and receive multicast datagrams. Use the UdpClient.JoinMulticastGroup(System.Net.IPAddress) method to subscribe a System.Net.Sockets.UdpClient to a multicast group. Use the UdpClient.DropMulticastGroup(System.Net.IPAddress) method to unsubscribe a System.Net.Sockets.UdpClient from a multicast group.