Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.net

Class MulticastSocket

java.lang.Object
|
+--java.net.DatagramSocket
   |
   +--java.net.MulticastSocket


public class MulticastSocket

extends DatagramSocket

This class models a multicast UDP socket. A multicast address is a class D internet address (one whose most significant bits are 1110). A multicast group consists of a multicast address and a well known port number. All members of the group listening on that address and port will receive all the broadcasts to the group.

Please note that applets are not allowed to use multicast sockets Written using on-line Java Platform 1.2 API Specification, as well as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). Status: Believed complete and correct.

Since:Authors:

Constructor Summary

MulticastSocket()

Create a MulticastSocket that this not bound to any address
MulticastSocket(int port)

Create a multicast socket bound to the specified port
MulticastSocket(java.net.SocketAddress address)

Create a multicast socket bound to the specified SocketAddress.

Method Summary

java.net.InetAddressgetInterface()

Returns the interface being used for multicast packets
booleangetLoopbackMode()

Checks if local loopback mode is enabled or not
java.net.NetworkInterfacegetNetworkInterface()

Gets the local network interface which is used to send multicast messages
bytegetTTL()

Returns the current value of the "Time to Live" option.
intgetTimeToLive()

Returns the current value of the "Time to Live" option.
voidjoinGroup(java.net.InetAddress mcastaddr)

Joins the specified mulitcast group.
voidjoinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Joins the specified mulitcast group on a specified interface.
voidleaveGroup(java.net.InetAddress mcastaddr)

Leaves the specified multicast group
voidleaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Leaves the specified mulitcast group on a specified interface.
synchronized voidsend(java.net.DatagramPacket p, byte ttl)

Sends a packet of data to a multicast address with a TTL that is different from the default TTL on this socket.
voidsetInterface(java.net.InetAddress addr)

Sets the interface to use for sending multicast packets.
voidsetLoopbackMode(boolean disable)

Disable/Enable local loopback of multicast packets.
voidsetNetworkInterface(java.net.NetworkInterface netIf)

Sets the local network interface used to send multicast messages
voidsetTTL(byte ttl)

Sets the "Time to Live" value for a socket.
voidsetTimeToLive(int ttl)

Sets the "Time to Live" value for a socket.

Constructor Details

MulticastSocket

public MulticastSocket()

Create a MulticastSocket that this not bound to any address

Throws:


MulticastSocket

public MulticastSocket(int port)

Create a multicast socket bound to the specified port

Parameters:

Throws:


MulticastSocket

public MulticastSocket(java.net.SocketAddress address)

Create a multicast socket bound to the specified SocketAddress.

Since:Parameters:

Throws:


Method Details

getInterface

public InetAddress getInterface()

Returns the interface being used for multicast packets

Returns:

Throws:


getLoopbackMode

public boolean getLoopbackMode()

Checks if local loopback mode is enabled or not

Since:Throws:


getNetworkInterface

public NetworkInterface getNetworkInterface()

Gets the local network interface which is used to send multicast messages

Since:Returns:

Throws:

See Also:


getTTL

public byte getTTL()

Returns the current value of the "Time to Live" option. This is the number of hops a packet can make before it "expires". This method id deprecated. Use getTimeToLive instead.

Returns:

Throws:

See Also:


getTimeToLive

public int getTimeToLive()

Returns the current value of the "Time to Live" option. This is the number of hops a packet can make before it "expires".

Since:Returns:

Throws:


joinGroup

public void joinGroup(java.net.InetAddress mcastaddr)

Joins the specified mulitcast group.

Parameters:

Throws:


joinGroup

public void joinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Joins the specified mulitcast group on a specified interface.

Since:Parameters:

Throws:

See Also:


leaveGroup

public void leaveGroup(java.net.InetAddress mcastaddr)

Leaves the specified multicast group

Parameters:

Throws:


leaveGroup

public void leaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Leaves the specified mulitcast group on a specified interface.

Since:Parameters:

Throws:

See Also:


send

public synchronized void send(java.net.DatagramPacket p, byte ttl)

Sends a packet of data to a multicast address with a TTL that is different from the default TTL on this socket. The default TTL for the socket is not changed.

Parameters:

Throws:


setInterface

public void setInterface(java.net.InetAddress addr)

Sets the interface to use for sending multicast packets.

Since:Parameters:

Throws:


setLoopbackMode

public void setLoopbackMode(boolean disable)

Disable/Enable local loopback of multicast packets. The option is used by the platform's networking code as a hint for setting whether multicast data will be looped back to the local socket. Because this option is a hint, applications that want to verify what loopback mode is set to should call #getLoopbackMode

Since:Parameters:

Throws:


setNetworkInterface

public void setNetworkInterface(java.net.NetworkInterface netIf)

Sets the local network interface used to send multicast messages

Since:Parameters:

Throws:

See Also:


setTTL

public void setTTL(byte ttl)

Sets the "Time to Live" value for a socket. The value must be between 1 and 255.

Parameters:

Throws:

See Also:


setTimeToLive

public void setTimeToLive(int ttl)

Sets the "Time to Live" value for a socket. The value must be between 1 and 255.

Since:Parameters:

Throws: