Top Description Inners Fields Constructors Methods
sun.nio.ch

public Class DatagramSocketAdaptor

extends MulticastSocket
Class Inheritance
Imports
java.io.IOException, .InterruptedIOException, .UncheckedIOException, java.lang.invoke.MethodHandle, .MethodHandles, .MethodHandles.Lookup, .MethodType, java.net.DatagramPacket, .DatagramSocket, .InetAddress, .InetSocketAddress, .MulticastSocket, .NetworkInterface, .SocketAddress, .SocketException, .SocketOption, .SocketTimeoutException, .StandardSocketOptions, java.nio.channels.AlreadyConnectedException, .ClosedChannelException, .ClosedByInterruptException, .DatagramChannel, .MembershipKey, java.util.Objects, .Set, java.util.concurrent.locks.ReentrantLock

A multicast datagram socket based on a datagram channel. This class overrides every public method defined by java.net.DatagramSocket and java.net.MulticastSocket. The methods in this class are defined in exactly the same order as in java.net.DatagramSocket and java.net.MulticastSocket so as to simplify tracking changes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DatagramSocketAdaptor.DatagramSockets

Provides access to non-public constants in DatagramSocket.

private static class
DatagramSocketAdaptor.NetworkInterfaces

Defines static methods to invoke non-public NetworkInterface methods.

Field Summary

Modifier and TypeField and Description
private final DatagramChannelImpl
private InetAddress
private final Object
private NetworkInterface
private final ReentrantLock
private volatile int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private InetAddress
anyInetAddress()

Returns the InetAddress representing anyLocalAddress.

private NetworkInterface
anyNetworkInterface()

Returns the placeholder for "any network interface", its index is 0.

public void
bind(SocketAddress
The address and port to bind to.
local
)

Overrides java.net.DatagramSocket.bind.

Binds this DatagramSocket to a specific address and port.

private static InetAddress

Returns:

the multicast group
checkGroup
(SocketAddress mcastaddr)

Checks a SocketAddress to ensure that it is a multicast address.

public void
close()

Overrides java.net.DatagramSocket.close.

Implements java.io.Closeable.close.

Closes this datagram socket.

public void
connect(InetAddress
the remote address for the socket
address
,
int
the remote port for the socket.
port
)

Overrides java.net.DatagramSocket.connect.

Connects the socket to a remote address for this socket.

public void
connect(SocketAddress
The remote address.
remote
)

Overrides java.net.DatagramSocket.connect.

Connects this socket to a remote socket address (IP address + port number).

private void
pack-priv static DatagramSocket
private NetworkInterface
defaultNetworkInterface()

Returns the default NetworkInterface to use when joining or leaving a multicast group and a network interface is not specified.

public void
disconnect()

Overrides java.net.DatagramSocket.disconnect.

Disconnects the socket.

private boolean
public boolean
getBroadcast()

Overrides java.net.DatagramSocket.getBroadcast.

Tests if SO_BROADCAST is enabled.

public DatagramChannel
getChannel()

Overrides java.net.DatagramSocket.getChannel.

Returns the unique java.nio.channels.DatagramChannel object associated with this datagram socket, if any.

public InetAddress
getInetAddress()

Overrides java.net.DatagramSocket.getInetAddress.

Returns the address to which this socket is connected.

public InetAddress
getInterface()

Overrides java.net.MulticastSocket.getInterface.

Deprecated

Retrieve the address of the network interface used for multicast packets.

private int
public InetAddress
getLocalAddress()

Overrides java.net.DatagramSocket.getLocalAddress.

Gets the local address to which the socket is bound.

public int
getLocalPort()

Overrides java.net.DatagramSocket.getLocalPort.

Returns the port number on the local host to which this socket is bound.

public SocketAddress
getLocalSocketAddress()

Overrides java.net.DatagramSocket.getLocalSocketAddress.

Returns the address of the endpoint this socket is bound to.

public boolean
getLoopbackMode()

Overrides java.net.MulticastSocket.getLoopbackMode.

Deprecated

Get the setting for local loopback of multicast datagrams.

public NetworkInterface
getNetworkInterface()

Overrides java.net.MulticastSocket.getNetworkInterface.

Get the multicast network interface set for outgoing multicast datagrams sent from this socket.

public <T> T
getOption(SocketOption<T>
The socket option
name
)

Overrides java.net.DatagramSocket.getOption.

Returns the value of a socket option.

public int
getPort()

Overrides java.net.DatagramSocket.getPort.

Returns the port number to which this socket is connected.

public int
getReceiveBufferSize()

Overrides java.net.DatagramSocket.getReceiveBufferSize.

Get value of the SO_RCVBUF option for this DatagramSocket, that is the buffer size, in bytes, used by the platform for input on this DatagramSocket.

public SocketAddress
getRemoteSocketAddress()

Overrides java.net.DatagramSocket.getRemoteSocketAddress.

Returns the address of the endpoint this socket is connected to, or null if it is unconnected.

public boolean
getReuseAddress()

Overrides java.net.DatagramSocket.getReuseAddress.

Tests if SO_REUSEADDR is enabled.

public int
getSendBufferSize()

Overrides java.net.DatagramSocket.getSendBufferSize.

Get value of the SO_SNDBUF option for this DatagramSocket, that is the buffer size, in bytes, used by the platform for output on this DatagramSocket.

public int
getSoTimeout()

Overrides java.net.DatagramSocket.getSoTimeout.

Retrieve setting for SO_TIMEOUT.

public int
getTimeToLive()

Overrides java.net.MulticastSocket.getTimeToLive.

Get the default time-to-live for multicast packets sent out on the socket.

public int
getTrafficClass()

Overrides java.net.DatagramSocket.getTrafficClass.

Gets traffic class or type-of-service in the IP datagram header for packets sent from this DatagramSocket.

public byte
getTTL()

Overrides java.net.MulticastSocket.getTTL.

Get the default time-to-live for multicast packets sent out on the socket.

public boolean
isBound()

Overrides java.net.DatagramSocket.isBound.

Returns the binding state of the socket.

public boolean
isClosed()

Overrides java.net.DatagramSocket.isClosed.

Returns whether the socket is closed or not.

public boolean
isConnected()

Overrides java.net.DatagramSocket.isConnected.

Returns the connection state of the socket.

public void
joinGroup(InetAddress
is the multicast address to join
group
)

Overrides java.net.MulticastSocket.joinGroup.

Deprecated

Joins a multicast group.

public void
joinGroup(SocketAddress
indicates the multicast address to join.
mcastaddr
,
NetworkInterface
specifies the local interface to receive multicast datagram packets, or null.
netIf
)

Overrides java.net.MulticastSocket.joinGroup.

Joins a multicast group.

public void
leaveGroup(InetAddress
is the multicast address to leave
group
)

Overrides java.net.MulticastSocket.leaveGroup.

Deprecated

Leave a multicast group.

public void
leaveGroup(SocketAddress
is the multicast address to leave. This should contain the same IP address than that used for joining the group.
mcastaddr
,
NetworkInterface
specifies the local interface or null to defer to the interface set for outgoing multicast datagrams. If null, and no interface has been set, the behaviour is unspecified: any interface may be selected or the operation may fail with a SocketException.
netIf
)

Overrides java.net.MulticastSocket.leaveGroup.

Leave a multicast group on a specified local interface.

private NetworkInterface
outgoingNetworkInterface()

Returns the outgoing NetworkInterface or null if not set.

public void
receive(DatagramPacket
the DatagramPacket into which to place the incoming data.
p
)

Overrides java.net.DatagramSocket.receive.

Receives a datagram packet from this socket.

public void
send(DatagramPacket
the DatagramPacket to be sent.
p
)

Overrides java.net.DatagramSocket.send.

Sends a datagram packet from this socket.

public void
send(DatagramPacket
is the packet to be sent. The packet should contain the destination multicast ip address and the data to be sent. One does not need to be the member of the group to send packets to a destination multicast address.
p
,
byte
optional time to live for multicast packet. default ttl is 1.
ttl
)

Overrides java.net.MulticastSocket.send.

Sends a datagram packet to the destination, with a TTL (time-to-live) other than the default for the socket.

private void
setBooleanOption(SocketOption<Boolean> name, boolean value)

public void
setBroadcast(boolean
whether or not to have broadcast turned on.
on
)

Overrides java.net.DatagramSocket.setBroadcast.

Enable/disable SO_BROADCAST.

public void
setInterface(InetAddress
the InetAddress
inf
)

Overrides java.net.MulticastSocket.setInterface.

Deprecated

Set the multicast network interface used by methods whose behavior would be affected by the value of the network interface.

private void
setIntOption(SocketOption<Integer> name, int value)

public void
setLoopbackMode(boolean
true to disable the LoopbackMode
disable
)

Overrides java.net.MulticastSocket.setLoopbackMode.

Deprecated

Disable/Enable local loopback of multicast datagrams.

public void
setNetworkInterface(NetworkInterface
the interface
netIf
)

Overrides java.net.MulticastSocket.setNetworkInterface.

Specify the network interface for outgoing multicast datagrams sent on this socket.

public <T> DatagramSocket
setOption(SocketOption<T>
The socket option
name
,
T
The value of the socket option. A value of null may be valid for some options.
value
)

Overrides java.net.DatagramSocket.setOption.

Sets the value of a socket option.

public void
setReceiveBufferSize(int
the size to which to set the receive buffer size, in bytes. This value must be greater than 0.
size
)

Overrides java.net.DatagramSocket.setReceiveBufferSize.

Sets the SO_RCVBUF option to the specified value for this DatagramSocket.

public void
setReuseAddress(boolean
whether to enable or disable the
on
)

Overrides java.net.DatagramSocket.setReuseAddress.

Enable/disable the SO_REUSEADDR socket option.

public void
setSendBufferSize(int
the size to which to set the send buffer size, in bytes. This value must be greater than 0.
size
)

Overrides java.net.DatagramSocket.setSendBufferSize.

Sets the SO_SNDBUF option to the specified value for this DatagramSocket.

public void
setSoTimeout(int
the specified timeout in milliseconds.
timeout
)

Overrides java.net.DatagramSocket.setSoTimeout.

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

public void
setTimeToLive(int
the time-to-live
ttl
)

Overrides java.net.MulticastSocket.setTimeToLive.

Set the default time-to-live for multicast packets sent out on this MulticastSocket in order to control the scope of the multicasts.

public void
setTrafficClass(int
an int value for the bitset.
tc
)

Overrides java.net.DatagramSocket.setTrafficClass.

Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket.

public void
setTTL(byte
the time-to-live
ttl
)

Overrides java.net.MulticastSocket.setTTL.

Set the default time-to-live for multicast packets sent out on this MulticastSocket in order to control the scope of the multicasts.

public Set<SocketOption<?>>
supportedOptions()

Overrides java.net.DatagramSocket.supportedOptions.

Returns a set of the socket options supported by this socket.