java.lang.Object | ||
↳ | java.net.DatagramSocket | |
↳ | java.net.MulticastSocket |
This class implements a multicast socket for sending and receiving IP multicast datagram packets.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a multicast socket, bound to any available port on the
localhost.
| |||||||||||
Constructs a multicast socket, bound to the specified port on the
localhost.
| |||||||||||
Constructs a
MulticastSocket bound to the host/port specified by
the SocketAddress , or an unbound DatagramSocket if the
SocketAddress is null . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the network address used by this socket.
| |||||||||||
Gets the state of the
SocketOptions.IP_MULTICAST_LOOP . | |||||||||||
Gets the network interface used by this socket.
| |||||||||||
This method is deprecated.
Replaced by
getTimeToLive() | |||||||||||
Gets the time-to-live (TTL) for multicast packets sent on this socket.
| |||||||||||
Adds this socket to the specified multicast group.
| |||||||||||
Adds this socket to the specified multicast group.
| |||||||||||
Removes this socket from the specified multicast group.
| |||||||||||
Removes this socket from the specified multicast group.
| |||||||||||
This method is deprecated.
use
setTimeToLive(int) .
| |||||||||||
Sets the interface address used by this socket.
| |||||||||||
Sets the
IP_MULTICAST_LOOP . | |||||||||||
Sets the network interface used by this socket.
| |||||||||||
This method is deprecated.
Replaced by
setTimeToLive(int) | |||||||||||
Sets the time-to-live (TTL) for multicast packets sent on this socket.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.net.DatagramSocket
| |||||||||||
From class java.lang.Object
|
Constructs a multicast socket, bound to any available port on the localhost.
IOException | if an error occurs creating or binding the socket. |
---|
Constructs a multicast socket, bound to the specified port on the localhost.
aPort | the port to bind on the localhost. |
---|
IOException | if an error occurs creating or binding the socket. |
---|
Constructs a 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. |
Gets the network address used by this socket. This is useful on multihomed machines.
SocketException | if an error occurs while getting the interface address. |
---|
Gets the state of the 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. |
---|
Gets the network interface used by this socket. This is useful on multihomed machines.
null
if no
interface is set.SocketException | if an error occurs while getting the interface. |
---|
This method is deprecated.
Replaced by getTimeToLive()
Gets the time-to-live (TTL) for multicast packets sent on this socket.
IOException | if an error occurs reading the default value. |
---|
Gets the time-to-live (TTL) for multicast packets sent on this socket.
IOException | if an error occurs reading the default value. |
---|
Adds this socket to the specified multicast group. A socket must join a group before data may be received. A socket may be a member of multiple groups but may join any group only once.
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. |
Adds this socket to the specified multicast group. A socket must join a group before data may be received. A socket may be a member of multiple groups but may join any group only once.
groupAddr | the multicast group to be joined. |
---|
IOException | if an error occurs while joining a group. |
---|
Removes this socket from the specified multicast group.
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 groupAddress is null . |
Removes this socket from the specified multicast group.
groupAddr | the multicast group to be left. |
---|
NullPointerException | if groupAddr is null . |
---|---|
IOException | if the specified group address is not a multicast address. |
SecurityException | if the caller is not authorized to leave the group. |
This method is deprecated.
use setTimeToLive(int)
.
Send the packet on this socket. The packet must satisfy the security policy before it may be sent.
pack | the DatagramPacket to send |
---|---|
ttl | the TTL setting for this transmission, overriding the socket default |
IOException | if an error occurs while sending data or setting options. |
---|
Sets the interface address used by this socket. This allows to send multicast packets on a different interface than the default interface of the local system. This is useful on multihomed machines.
addr | the multicast interface network address to set. |
---|
SocketException | if an error occurs while setting the network interface address option. |
---|
Sets the IP_MULTICAST_LOOP
.
disable | true to disable loopback |
---|
SocketException | if the socket is closed or the option is invalid. |
---|
Sets the network interface used by this socket. This is useful for multihomed machines.
netInterface | the multicast network interface to set. |
---|
SocketException | if an error occurs while setting the network interface option. |
---|
This method is deprecated.
Replaced by setTimeToLive(int)
Sets the time-to-live (TTL) for multicast packets sent on this socket. Valid TTL values are between 0 and 255 inclusive.
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. |
---|
Sets the time-to-live (TTL) for multicast packets sent on this socket. Valid TTL values are between 0 and 255 inclusive.
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. |
---|