Share via


MulticastSocket.Send(DatagramPacket, SByte) Method

Definition

Caution

deprecated

Sends a datagram packet to the destination, with a TTL (time- to-live) other than the default for the socket.

[Android.Runtime.Register("send", "(Ljava/net/DatagramPacket;B)V", "GetSend_Ljava_net_DatagramPacket_BHandler")]
[System.Obsolete("deprecated")]
public virtual void Send (Java.Net.DatagramPacket? p, sbyte ttl);
[<Android.Runtime.Register("send", "(Ljava/net/DatagramPacket;B)V", "GetSend_Ljava_net_DatagramPacket_BHandler")>]
[<System.Obsolete("deprecated")>]
override this.Send : Java.Net.DatagramPacket * sbyte -> unit

Parameters

p
DatagramPacket

is the packet to be sent. The packet should contain the destination multicast ip address and the data to be sent. One does not need to be the member of the group to send packets to a destination multicast address.

ttl
SByte

optional time to live for multicast packet. default ttl is 1.

Attributes

Exceptions

if an error occurs.

Remarks

Sends a datagram packet to the destination, with a TTL (time- to-live) other than the default for the socket. This method need only be used in instances where a particular TTL is desired; otherwise it is preferable to set a TTL once on the socket, and use that default TTL for all packets. This method does <B>not </B> alter the default TTL for the socket. Its behavior may be affected by setInterface.

If there is a security manager, 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() and ttl as its arguments. 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.

This member is deprecated. Use the following code or its equivalent instead: ...... int ttl = mcastSocket.getTimeToLive(); mcastSocket.setTimeToLive(newttl); mcastSocket.send(p); mcastSocket.setTimeToLive(ttl); ......

Java documentation for java.net.MulticastSocket.send(java.net.DatagramPacket, byte).

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