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
local host.
| |||||||||||
Constructs a multicast socket, bound to the specified
port on the
local host. | |||||||||||
Constructs a
MulticastSocket bound to the address and port specified by
localAddress , or an unbound MulticastSocket if localAddress == null . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns an address of the outgoing network interface used by this socket.
| |||||||||||
Returns true if multicast loopback is disabled.
| |||||||||||
Returns the outgoing network interface used by this socket.
| |||||||||||
This method was deprecated
in API level 1.
Use
getTimeToLive() instead.
| |||||||||||
Returns 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 was deprecated
in API level 1.
Use
setTimeToLive(int) instead.
| |||||||||||
Sets the outgoing network interface used by this socket.
| |||||||||||
Disables multicast loopback if
disable == true . | |||||||||||
Sets the outgoing network interface used by this socket to the given
networkInterface . | |||||||||||
This method was deprecated
in API level 1.
Use
setTimeToLive(int) instead.
| |||||||||||
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
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
Constructs a multicast socket, bound to any available port on the local host.
IOException | if an error occurs. |
---|
Constructs a multicast socket, bound to the specified port
on the
local host.
IOException | if an error occurs. |
---|
Constructs a MulticastSocket
bound to the address and port specified by
localAddress
, or an unbound MulticastSocket
if localAddress == null
.
IllegalArgumentException | if localAddress is not supported (because it's not
an InetSocketAddress , say). |
---|---|
IOException | if an error occurs. |
Returns an address of the outgoing network interface used by this socket. To avoid
inherent unpredictability, new code should use getNetworkInterface()
instead.
SocketException | if an error occurs. |
---|
Returns true if multicast loopback is disabled.
See IP_MULTICAST_LOOP
, and note that the sense of this is the
opposite of the underlying Unix IP_MULTICAST_LOOP
.
SocketException | if an error occurs. |
---|
Returns the outgoing network interface used by this socket.
SocketException | if an error occurs. |
---|
This method was deprecated
in API level 1.
Use getTimeToLive()
instead.
Returns the time-to-live (TTL) for multicast packets sent on this socket.
IOException | if an error occurs. |
---|
Returns the time-to-live (TTL) for multicast packets sent on this socket.
IOException | if an error occurs. |
---|
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. |
---|---|
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. |
---|
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. |
---|---|
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. |
This method was deprecated
in API level 1.
Use setTimeToLive(int)
instead.
Sends the given packet
on this socket, using the given ttl
. This method is
deprecated because it modifies the TTL socket option for this socket twice on each call.
IOException | if an error occurs. |
---|
Sets the outgoing network interface used by this socket. The interface used is the first
interface found to have the given address
. To avoid inherent unpredictability,
new code should use getNetworkInterface()
instead.
SocketException | if an error occurs. |
---|
Disables multicast loopback if disable == true
.
See IP_MULTICAST_LOOP
, and note that the sense of this is the
opposite of the underlying Unix IP_MULTICAST_LOOP
: true means disabled, false
means enabled.
SocketException | if an error occurs. |
---|
Sets the outgoing network interface used by this socket to the given
networkInterface
.
SocketException | if an error occurs. |
---|
This method was deprecated
in API level 1.
Use setTimeToLive(int)
instead.
Sets the time-to-live (TTL) for multicast packets sent on this socket. Valid TTL values are between 0 and 255 inclusive.
IOException | if an error occurs. |
---|
Sets the time-to-live (TTL) for multicast packets sent on this socket. Valid TTL values are between 0 and 255 inclusive.
IOException | if an error occurs. |
---|