public class MulticastSocket extends DatagramSocket
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.
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
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, setTrafficClasspublic MulticastSocket() throws IOException
IOException - If an error occursSecurityException - If a security manager exists and its
checkListen method doesn't allow the operationpublic MulticastSocket(int port) throws IOException
port - The port to bind toIOException - If an error occursSecurityException - If a security manager exists and its
checkListen method doesn't allow the operationpublic MulticastSocket(SocketAddress address) throws IOException
address - The SocketAddress the multicast socket will be bound toIOException - If an error occursSecurityException - If a security manager exists and its
checkListen method doesn't allow the operationpublic InetAddress getInterface() throws SocketException
SocketException - If an error occurspublic byte getTTL() throws IOException
getTimeToLive instead.IOException - If an error occursgetTimeToLive()public int getTimeToLive() throws IOException
IOException - If an error occurspublic void setInterface(InetAddress addr) throws SocketException
addr - The new interface to use.SocketException - If an error occurs.public void setNetworkInterface(NetworkInterface netIf) throws SocketException
netIf - The local network interface used to send multicast messagesSocketException - If an error occursgetNetworkInterface()public NetworkInterface getNetworkInterface() throws SocketException
SocketException - If an error occurssetNetworkInterface(NetworkInterface netIf)public void setLoopbackMode(boolean disable) throws SocketException
disable - True to disable loopback modeSocketException - If an error occurspublic boolean getLoopbackMode() throws SocketException
SocketException - If an error occurspublic void setTTL(byte ttl) throws IOException
setTimeToLivettl - The new TTL valueIOException - If an error occurssetTimeToLive(int ttl)public void setTimeToLive(int ttl) throws IOException
ttl - The new TTL valueIOException - If an error occurspublic void joinGroup(InetAddress mcastaddr) throws IOException
mcastaddr - The address of the group to joinIOException - If an error occursSecurityException - If a security manager exists and its
checkMulticast method doesn't allow the operationpublic void leaveGroup(InetAddress mcastaddr) throws IOException
mcastaddr - The address of the group to leaveIOException - If an error occursSecurityException - If a security manager exists and its
checkMulticast method doesn't allow the operationpublic void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
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
#setNetworkInterfaceIOException - If an error occursIllegalArgumentException - If address type is not supportedSecurityException - If a security manager exists and its
checkMulticast method doesn't allow the operationsetInterface(InetAddress addr),
setNetworkInterface(NetworkInterface netIf)public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
mcastaddr - The multicast address to leavenetIf - The local networki interface or null to defer to the
interface set by setInterface or setNetworkInterfaceIOException - If an error occursIllegalArgumentException - If address type is not supportedSecurityException - If a security manager exists and its
checkMulticast method doesn't allow the operationsetInterface(InetAddress addr),
setNetworkInterface(NetworkInterface netIf)public void send(DatagramPacket packet, byte ttl) throws IOException
packet - The packet of data to sendttl - The TTL for this packetIOException - If an error occursSecurityException - If a security manager exists and its
checkConnect or checkMulticast method doesn't allow the operation