Share via


DatagramSocket.Receive(DatagramPacket) Method

Definition

Receives a datagram packet from this socket.

[Android.Runtime.Register("receive", "(Ljava/net/DatagramPacket;)V", "GetReceive_Ljava_net_DatagramPacket_Handler")]
public virtual void Receive (Java.Net.DatagramPacket? p);
[<Android.Runtime.Register("receive", "(Ljava/net/DatagramPacket;)V", "GetReceive_Ljava_net_DatagramPacket_Handler")>]
abstract member Receive : Java.Net.DatagramPacket -> unit
override this.Receive : Java.Net.DatagramPacket -> unit

Parameters

p
DatagramPacket

the DatagramPacket into which to place the incoming data.

Attributes

Exceptions

if an error occurs while receiving the packet.

Remarks

Receives a datagram packet from this socket. When this method returns, the DatagramPacket's buffer is filled with the data received. The datagram packet also contains the sender's IP address, and the port number on the sender's machine.

This method blocks until a datagram is received. The length field of the datagram packet object contains the length of the received message. If the message is longer than the packet's length, the message is truncated.

If there is a security manager, a packet cannot be received if the security manager's checkAccept method does not allow it.

Java documentation for java.net.DatagramSocket.receive(java.net.DatagramPacket).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to