Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.net
Class MulticastSocket  view MulticastSocket download MulticastSocket.java

java.lang.Object
  extended byjava.net.DatagramSocket
      extended byjava.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:
1.1

Field Summary
 
Fields inherited from class java.net.DatagramSocket
 
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(SocketAddress address)
          Create a multicast socket bound to the specified SocketAddress.
 
Method Summary
 InetAddress getInterface()
          Returns the interface being used for multicast packets
 boolean getLoopbackMode()
          Checks if local loopback mode is enabled
 NetworkInterface getNetworkInterface()
          Gets the local network interface which is used to send multicast messages
 int getTimeToLive()
          Returns the current value of the "Time to Live" option.
 byte getTTL()
          Deprecated. 1.2 Replaced by getTimeToLive()
 void joinGroup(InetAddress mcastaddr)
          Joins the specified multicast group.
 void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
          Joins the specified mulitcast group on a specified interface.
 void leaveGroup(InetAddress mcastaddr)
          Leaves the specified multicast group
 void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
          Leaves the specified mulitcast group on a specified interface.
 void send(DatagramPacket packet, byte ttl)
          Deprecated.  
 void setInterface(InetAddress addr)
          Sets the interface to use for sending multicast packets.
 void setLoopbackMode(boolean disable)
          Disable/Enable local loopback of multicast packets.
 void setNetworkInterface(NetworkInterface netIf)
          Sets the local network interface used to send multicast messages
 void setTimeToLive(int ttl)
          Sets the "Time to Live" value for a socket.
 void setTTL(byte ttl)
          Deprecated. 1.2 Replaced by setTimeToLive
 
Methods inherited from class java.net.DatagramSocket
bind, close, connect, connect, disconnect, getBroadcast, getChannel, getImpl, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isBound, isClosed, isConnected, receive, send, setBroadcast, setDatagramSocketImplFactory, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MulticastSocket

public MulticastSocket()
                throws java.io.IOException
Create a MulticastSocket that this not bound to any address


MulticastSocket

public MulticastSocket(int port)
                throws java.io.IOException
Create a multicast socket bound to the specified port


MulticastSocket

public MulticastSocket(SocketAddress address)
                throws java.io.IOException
Create a multicast socket bound to the specified SocketAddress.

Since:
1.4
Method Detail

getInterface

public InetAddress getInterface()
                         throws SocketException
Returns the interface being used for multicast packets


getTTL

public byte getTTL()
            throws java.io.IOException
Deprecated. 1.2 Replaced by getTimeToLive()

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.


getTimeToLive

public int getTimeToLive()
                  throws java.io.IOException
Returns the current value of the "Time to Live" option. This is the number of hops a packet can make before it "expires".

Since:
1.2

setInterface

public void setInterface(InetAddress addr)
                  throws SocketException
Sets the interface to use for sending multicast packets.

Since:
1.4

setNetworkInterface

public void setNetworkInterface(NetworkInterface netIf)
                         throws SocketException
Sets the local network interface used to send multicast messages

Since:
1.4

getNetworkInterface

public NetworkInterface getNetworkInterface()
                                     throws SocketException
Gets the local network interface which is used to send multicast messages

Since:
1.4

setLoopbackMode

public void setLoopbackMode(boolean disable)
                     throws SocketException
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:
1.4

getLoopbackMode

public boolean getLoopbackMode()
                        throws SocketException
Checks if local loopback mode is enabled

Since:
1.4

setTTL

public void setTTL(byte ttl)
            throws java.io.IOException
Deprecated. 1.2 Replaced by setTimeToLive

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


setTimeToLive

public void setTimeToLive(int ttl)
                   throws java.io.IOException
Sets the "Time to Live" value for a socket. The value must be between 1 and 255.

Since:
1.2

joinGroup

public void joinGroup(InetAddress mcastaddr)
               throws java.io.IOException
Joins the specified multicast group.


leaveGroup

public void leaveGroup(InetAddress mcastaddr)
                throws java.io.IOException
Leaves the specified multicast group


joinGroup

public void joinGroup(SocketAddress mcastaddr,
                      NetworkInterface netIf)
               throws java.io.IOException
Joins the specified mulitcast group on a specified interface.

Since:
1.4

leaveGroup

public void leaveGroup(SocketAddress mcastaddr,
                       NetworkInterface netIf)
                throws java.io.IOException
Leaves the specified mulitcast group on a specified interface.

Since:
1.4

send

public void send(DatagramPacket packet,
                 byte ttl)
          throws java.io.IOException
Deprecated.  

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.