0 out of 1 rated this helpful - Rate this topic

UdpClient Members

Provides User Datagram Protocol (UDP) network services.

The UdpClient type exposes the following members.

  Name Description
Public method Supported by the .NET Compact Framework UdpClient Overloaded. Initializes a new instance of the UdpClient class.
Top
  Name Description
Public method BeginReceive Receives a datagram from a remote host asynchronously.
Public method BeginSend Overloaded. Sends a datagram to a remote host asynchronously.
Public method Supported by the .NET Compact Framework Close Closes the UDP connection.
Public method Supported by the .NET Compact Framework Connect Overloaded. Establishes a default remote host.
Protected method Supported by the .NET Compact Framework Dispose Releases the unmanaged resources used by the UdpClient and optionally releases the managed resources.
Public method Supported by the .NET Compact Framework DropMulticastGroup Overloaded. Leaves a multicast group.
Public method EndReceive Ends a pending asynchronous receive.
Public method EndSend Ends a pending asynchronous send.
Public method Supported by the .NET Compact Framework Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by the .NET Compact Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the .NET Compact Framework GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Supported by the .NET Compact Framework GetType Gets the type of the current instance. (Inherited from Object.)
Public method Supported by the .NET Compact Framework JoinMulticastGroup Overloaded. Adds a UdpClient to a multicast group.
Protected method Supported by the .NET Compact Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the .NET Compact Framework Receive Returns a UDP datagram that was sent by a remote host.
Public method Supported by the .NET Compact Framework Send Overloaded. Sends a UDP datagram to a remote host.
Public method Supported by the .NET Compact Framework ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Protected property Supported by the .NET Compact Framework Active Gets or sets a value indicating whether a default remote host has been established.
Public property Available Gets the amount of data received from the network that is available to read.
Public property Supported by the .NET Compact Framework Client Gets or sets the underlying network Socket.
Public property DontFragment Gets or sets a Boolean value that specifies whether the UdpClient allows Internet Protocol (IP) datagrams to be fragmented.
Public property EnableBroadcast Gets or sets a Boolean value that specifies whether the UdpClient may send or receive broadcast packets.
Public property ExclusiveAddressUse Gets or sets a Boolean value that specifies whether the UdpClient allows only one client to use a port.
Public property MulticastLoopback Gets or sets a Boolean value that specifies whether outgoing multicast packets are delivered to the sending application.
Public property Ttl Gets or sets a value that specifies the Time to Live (TTL) value of Internet Protocol (IP) packets sent by the UdpClient.
Top
  Name Description
Explicit interface implemetation Private method Supported by the .NET Compact Framework IDisposable.Dispose Infrastructure. Releases all resources used by the UdpClient.
Top
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Use of Receive method

The use of the Receive method has one or more options that are not covered in the main page. The following demonstrates one use of the Receive method. Readers are encouraged to provide more examples.

const int listenPort = 11000;

string received_data;

byte[] receive_byte_array;

// Note that the constructor accepts the port number as an argument.

UdpClient listener = new UdpClient(listenPort);

// This prepares to listen for a UDP broadcast on any IP address but only on the port specified.

IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);

// Next we make a blocking call and wait for received data.

receive_byte_array = listener.Receive( ref groupEP );

// If the data is ASCII text, it must be converted before being used as text.

received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);