public class MultiplexedDatagramSocket extends DelegatingDatagramSocket implements MultiplexedXXXSocket
Modifier and Type | Field and Description |
---|---|
private DatagramPacketFilter |
filter
The DatagramPacketFilter which determines which
DatagramPackets read from the network by
multiplexing
are to be received through this instance. |
private MultiplexingDatagramSocket |
multiplexing
The MultiplexingDatagramSocket which does the actual reading
from the network and which forwards DatagramPackets accepted by
filter for receipt to this instance. |
(package private) List<DatagramPacket> |
received
The list of DatagramPackets to be received through this
DatagramSocket i.e.
|
delegate
Constructor and Description |
---|
MultiplexedDatagramSocket(MultiplexingDatagramSocket multiplexing,
DatagramPacketFilter filter)
Initializes a new MultiplexedDatagramSocket which is unbound and
filters DatagramPackets away from a specific
MultiplexingDatagramSocket using a specific
DatagramPacketFilter.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this datagram socket.
|
DatagramPacketFilter |
getFilter()
Gets the
DatagramPacketFilter which determines which
DatagramPacket s read from the network are to be received through
this socket. |
void |
receive(DatagramPacket p)
Receives a datagram packet from this socket.
|
bind, connect, connect, disconnect, getBroadcast, getChannel, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isBound, isClosed, isConnected, logNonStun, send, setBroadcast, setDefaultDelegateFactory, setDefaultReceiveBufferSize, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass
setDatagramSocketImplFactory
private final DatagramPacketFilter filter
multiplexing
are to be received through this instance.private final MultiplexingDatagramSocket multiplexing
filter
for receipt to this instance.final List<DatagramPacket> received
filter
.MultiplexedDatagramSocket(MultiplexingDatagramSocket multiplexing, DatagramPacketFilter filter) throws SocketException
multiplexing
- the MultiplexingDatagramSocket which does
the actual reading from the network and which forwards
DatagramPackets accepted by the specified filter to the
new instancefilter
- the DatagramPacketFilter which determines which
DatagramPackets read from the network by the specified
multiplexing are to be received through the new instanceSocketException
- if the socket could not be openedpublic void close()
Any thread currently blocked in receive(DatagramPacket)
upon
this socket will throw a SocketException
.
close
in interface Closeable
close
in interface AutoCloseable
close
in class DelegatingDatagramSocket
DatagramSocket.close()
public DatagramPacketFilter getFilter()
DatagramPacketFilter
which determines which
DatagramPacket
s read from the network are to be received through
this socket.getFilter
in interface MultiplexedXXXSocket
DatagramPacketFilter
which determines which
DatagramPacket
s read from the network are to be received through
this socketpublic void receive(DatagramPacket p) throws IOException
This method blocks until a datagram is received. The length field of the datagram packet object contains the length of the received message. If the message is longer than the packet's length, the message is truncated.
If there is a security manager, a packet cannot be received if the security manager's checkAccept method does not allow it.
receive
in class DelegatingDatagramSocket
p
- the DatagramPacket into which to place the incoming
dataIOException
- if an I/O error occursDatagramSocket.receive(DatagramPacket)
Copyright © 2018. All rights reserved.