Freigeben über


DatagramSocket.Send(DatagramPacket) Method

Definition

Sends a datagram packet from this socket.

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

Parameters

p
DatagramPacket

the DatagramPacket to be sent.

Attributes

Exceptions

if an error occurs while sending the packet.

Remarks

Sends a datagram packet from this socket. The DatagramPacket includes information indicating the data to be sent, its length, the IP address of the remote host, and the port number on the remote host.

If there is a security manager, and the socket is not currently connected to a remote address, this method first performs some security checks. First, if p.getAddress().isMulticastAddress() is true, this method calls the security manager's checkMulticast method with p.getAddress() as its argument. If the evaluation of that expression is false, this method instead calls the security manager's checkConnect method with arguments p.getAddress().getHostAddress() and p.getPort(). Each call to a security manager method could result in a SecurityException if the operation is not allowed.

Java documentation for java.net.DatagramSocket.send(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