|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.net.DatagramSocket
java.net.MulticastSocket
public 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.
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.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MulticastSocket() throws IOException
IOException
- If an error occurs
SecurityException
- If a security manager exists and its
checkListen method doesn't allow the operationpublic MulticastSocket(int port) throws IOException
port
- The port to bind to
IOException
- If an error occurs
SecurityException
- 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 to
IOException
- If an error occurs
SecurityException
- If a security manager exists and its
checkListen method doesn't allow the operationMethod Detail |
---|
public 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 messages
SocketException
- 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 mode
SocketException
- If an error occurspublic boolean getLoopbackMode() throws SocketException
SocketException
- If an error occurspublic void setTTL(byte ttl) throws IOException
setTimeToLive
ttl
- The new TTL value
IOException
- If an error occurssetTimeToLive(int ttl)
public void setTimeToLive(int ttl) throws IOException
ttl
- The new TTL value
IOException
- If an error occurspublic void joinGroup(InetAddress mcastaddr) throws IOException
mcastaddr
- The address of the group to join
IOException
- If an error occurs
SecurityException
- 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 leave
IOException
- If an error occurs
SecurityException
- 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
#setNetworkInterface
IOException
- If an error occurs
IllegalArgumentException
- If address type is not supported
SecurityException
- 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 setNetworkInterface
IOException
- If an error occurs
IllegalArgumentException
- If address type is not supported
SecurityException
- 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 packet
IOException
- If an error occurs
SecurityException
- If a security manager exists and its
checkConnect or checkMulticast method doesn't allow the operation
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |