|
Build 1.1_r1 (from source) | |||||||||
| 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 implements a multicast socket for sending and receiving IP multicast datagram packets.
DatagramSocket| Field Summary | |
|---|---|
(package private) static int |
SO_REUSEPORT
|
| Fields inherited from class java.net.DatagramSocket |
|---|
address, factory, impl, isBound, port |
| Constructor Summary | |
|---|---|
MulticastSocket()
Constructs a multicast socket, bound to any available port on the localhost. |
|
MulticastSocket(int aPort)
Constructs a multicast socket, bound to the specified port on the localhost. |
|
MulticastSocket(SocketAddress localAddr)
Constructs a MulticastSocket bound to the host/port specified by
the SocketAddress, or an unbound DatagramSocket if the
SocketAddress is null. |
|
| Method Summary | |
|---|---|
(package private) void |
createSocket(int aPort,
InetAddress addr)
|
InetAddress |
getInterface()
Gets the network address used by this socket. |
boolean |
getLoopbackMode()
Gets the state of the SocketOptions.IP_MULTICAST_LOOP. |
NetworkInterface |
getNetworkInterface()
Gets the network interface used by this socket. |
int |
getTimeToLive()
Gets the time-to-live (TTL) for multicast packets sent on this socket. |
byte |
getTTL()
Deprecated. Replaced by getTimeToLive() |
(package private) boolean |
isMulticastSocket()
Indicates whether this socket is multicast or not. |
void |
joinGroup(InetAddress groupAddr)
Adds this socket to the specified multicast group. |
void |
joinGroup(SocketAddress groupAddress,
NetworkInterface netInterface)
Adds this socket to the specified multicast group. |
void |
leaveGroup(InetAddress groupAddr)
Removes this socket from the specified multicast group. |
void |
leaveGroup(SocketAddress groupAddress,
NetworkInterface netInterface)
Removes this socket from the specified multicast group. |
void |
send(DatagramPacket pack,
byte ttl)
Deprecated. use setTimeToLive(int). |
void |
setInterface(InetAddress addr)
Sets the interface address used by this socket. |
void |
setLoopbackMode(boolean loop)
Sets the SocketOptions.IP_MULTICAST_LOOP. |
void |
setNetworkInterface(NetworkInterface netInterface)
Sets the network interface used by this socket. |
void |
setTimeToLive(int ttl)
Sets the time-to-live (TTL) for multicast packets sent on this socket. |
void |
setTTL(byte ttl)
Deprecated. Replaced by setTimeToLive(int) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final int SO_REUSEPORT
| Constructor Detail |
|---|
public MulticastSocket()
throws IOException
IOException - if an error occurs creating or binding the socket.
public MulticastSocket(int aPort)
throws IOException
aPort - the port to bind on the localhost.
IOException - if an error occurs creating or binding the socket.
public MulticastSocket(SocketAddress localAddr)
throws IOException
MulticastSocket bound to the host/port specified by
the SocketAddress, or an unbound DatagramSocket if the
SocketAddress is null.
localAddr - the local machine address and port to bind to.
IllegalArgumentException - if the SocketAddress is not supported.
IOException - if an error occurs creating or binding the socket.| Method Detail |
|---|
public InetAddress getInterface()
throws SocketException
SocketException - if an error occurs while getting the interface address.
public NetworkInterface getNetworkInterface()
throws SocketException
null if no
interface is set.
SocketException - if an error occurs while getting the interface.
public int getTimeToLive()
throws IOException
IOException - if an error occurs reading the default value.
@Deprecated
public byte getTTL()
throws IOException
getTimeToLive()
IOException - if an error occurs reading the default value.getTimeToLive()boolean isMulticastSocket()
DatagramSocket
isMulticastSocket in class DatagramSocketfalse.
public void joinGroup(InetAddress groupAddr)
throws IOException
groupAddr - the multicast group to be joined.
IOException - if an error occurs while joining a group.
public void joinGroup(SocketAddress groupAddress,
NetworkInterface netInterface)
throws IOException
groupAddress - the multicast group to be joined.netInterface - the network interface on which the datagram packets will be
received.
IOException - if the specified address is not a multicast address.
SecurityException - if the caller is not authorized to join the group.
IllegalArgumentException - if no multicast group is specified.
public void leaveGroup(InetAddress groupAddr)
throws IOException
groupAddr - the multicast group to be left.
IOException - if the specified group address is not a multicast address.
SecurityException - if the caller is not authorized to leave the group.
public void leaveGroup(SocketAddress groupAddress,
NetworkInterface netInterface)
throws IOException
groupAddress - the multicast group to be left.netInterface - the network interface on which the addresses should be
dropped.
IOException - if the specified group address is not a multicast address.
SecurityException - if the caller is not authorized to leave the group.
IllegalArgumentException - if no multicast group is specified.
@Deprecated
public void send(DatagramPacket pack,
byte ttl)
throws IOException
setTimeToLive(int).
pack - the DatagramPacket to sendttl - the TTL setting for this transmission, overriding the socket
default
IOException - if an error occurs while sending data or setting options.
public void setInterface(InetAddress addr)
throws SocketException
addr - the multicast interface network address to set.
SocketException - if an error occurs while setting the network interface
address option.
public void setNetworkInterface(NetworkInterface netInterface)
throws SocketException
netInterface - the multicast network interface to set.
SocketException - if an error occurs while setting the network interface
option.
public void setTimeToLive(int ttl)
throws IOException
ttl - the default time-to-live field value for packets sent on this
socket. 0 <= ttl <= 255.
IOException - if an error occurs while setting the TTL option value.
@Deprecated
public void setTTL(byte ttl)
throws IOException
setTimeToLive(int)
ttl - the default time-to-live field value for packets sent on this
socket: 0 <= ttl <= 255.
IOException - if an error occurs while setting the TTL option value.setTimeToLive(int)
void createSocket(int aPort,
InetAddress addr)
throws SocketException
createSocket in class DatagramSocketSocketException
public boolean getLoopbackMode()
throws SocketException
SocketOptions.IP_MULTICAST_LOOP.
true if the IP multicast loop is enabled, false
otherwise.
SocketException - if the socket is closed or the option is invalid.
public void setLoopbackMode(boolean loop)
throws SocketException
SocketOptions.IP_MULTICAST_LOOP.
loop - the value for the socket option socket SocketOptions.IP_MULTICAST_LOOP.
SocketException - if the socket is closed or the option is invalid.
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||