java.net
Class MulticastSocket
java.lang.Object
|
+--java.net.DatagramSocket
|
+--java.net.MulticastSocket
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:- Warren Levy <warrenl@cygnus.com>
- Aaron M. Renn (arenn@urbanophile.com) (Documentation comments)
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:
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:
- The local network interface to send multicast messages
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:
IOException
- If an error occursSecurityException
- If a security manager exists and its
checkConnect or checkMulticast method doesn't allow the operation
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:
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.