java.net
Class 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.
bind , close , connect , connect , disconnect , getBroadcast , getChannel , getInetAddress , getLocalAddress , getLocalPort , getLocalSocketAddress , getPort , getReceiveBufferSize , getRemoteSocketAddress , getReuseAddress , getSendBufferSize , getSoTimeout , getTrafficClass , isBound , isClosed , isConnected , receive , send , setBroadcast , setDatagramSocketImplFactory , setReceiveBufferSize , setReuseAddress , setSendBufferSize , setSoTimeout , setTrafficClass |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
MulticastSocket
public MulticastSocket(int port)
throws IOException
Create a multicast socket bound to the specified port
port
- The port to bind to
MulticastSocket
public MulticastSocket(SocketAddress address)
throws IOException
Create a multicast socket bound to the specified SocketAddress.
address
- The SocketAddress the multicast socket will be bound to
getLoopbackMode
public boolean getLoopbackMode()
throws SocketException
Checks if local loopback mode is enabled
- true if loopback mode is enabled, false otherwise
getNetworkInterface
public NetworkInterface getNetworkInterface()
throws SocketException
Gets the local network interface which is used to send multicast messages
- The local network interface to send multicast messages
MulticastSocket.setNetworkInterface(NetworkInterface netIf)
getTTL
public byte getTTL()
throws IOException
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 IOException
Returns the current value of the "Time to Live" option. This is the
number of hops a packet can make before it "expires".
joinGroup
public void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
throws IOException
Joins the specified mulitcast group on a specified interface.
mcastaddr
- The multicast address to joinnetIf
- The local network interface to receive the multicast
messages on or null to defer the interface set by #setInterface or
#setNetworkInterface
MulticastSocket.setInterface(InetAddress addr)
, MulticastSocket.setNetworkInterface(NetworkInterface netIf)
leaveGroup
public void leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
throws IOException
Leaves the specified mulitcast group on a specified interface.
mcastaddr
- The multicast address to leavenetIf
- The local networki interface or null to defer to the
interface set by setInterface or setNetworkInterface
MulticastSocket.setInterface(InetAddress addr)
, MulticastSocket.setNetworkInterface(NetworkInterface netIf)
send
public void send(DatagramPacket packet,
byte ttl)
throws IOException
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.
packet
- The packet of data to sendttl
- The TTL for this packet
IOException
- If an error occursSecurityException
- If a security manager exists and its
checkConnect or checkMulticast method doesn't allow the operation
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
disable
- True to disable loopback mode
setTTL
public void setTTL(byte ttl)
throws IOException
1.2 Replaced by setTimeToLive
Sets the "Time to Live" value for a socket. The value must be between
1 and 255.
MulticastSocket.setTimeToLive(int ttl)
setTimeToLive
public void setTimeToLive(int ttl)
throws IOException
Sets the "Time to Live" value for a socket. The value must be between
0 and 255, inclusive.
MulticastSocket.java -- Class for using multicast sockets
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.