protected class AbstractUdpListener.MySocket extends DatagramSocket
Modifier and Type | Field and Description |
---|---|
private boolean |
closed
The flag which indicates that this DatagramSocket has been
closed.
|
private ArrayBlockingQueue<AbstractUdpListener.Buffer> |
queue
The FIFO which acts as a buffer for this socket.
|
private static int |
QUEUE_SIZE
The size of
queue . |
private QueueStatistics |
queueStatistics
The
QueueStatistics instance optionally used to collect and
print detailed statistics about queue . |
private InetSocketAddress |
remoteAddress
The remote address that is associated with this socket.
|
Constructor and Description |
---|
MySocket(InetSocketAddress remoteAddress)
Initializes a new MySocket instance with the given
remote address.
|
Modifier and Type | Method and Description |
---|---|
void |
addBuffer(AbstractUdpListener.Buffer buf)
Adds pkt to this socket.
|
void |
close()
Removes the association of the remote address with this socket from
the harvester's map.
|
InetAddress |
getInetAddress() |
InetAddress |
getLocalAddress()
Delegates to the actual socket of the harvester.
|
int |
getLocalPort()
Delegates to the actual socket of the harvester.
|
SocketAddress |
getLocalSocketAddress()
Delegates to the actual socket of the harvester.
|
int |
getPort() |
SocketAddress |
getRemoteSocketAddress() |
void |
receive(DatagramPacket p)
Reads the data from the first element of
queue into
p. |
void |
send(DatagramPacket p)
Delegates to the actual socket of the harvester.
|
bind, connect, connect, disconnect, getBroadcast, getChannel, getReceiveBufferSize, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isBound, isClosed, isConnected, setBroadcast, setDatagramSocketImplFactory, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass
private static final int QUEUE_SIZE
queue
.private final ArrayBlockingQueue<AbstractUdpListener.Buffer> queue
private final QueueStatistics queueStatistics
QueueStatistics
instance optionally used to collect and
print detailed statistics about queue
.private InetSocketAddress remoteAddress
private boolean closed
MySocket(InetSocketAddress remoteAddress) throws SocketException
remoteAddress
- the remote address to be associated with the
new instance.SocketException
public void addBuffer(AbstractUdpListener.Buffer buf)
public InetAddress getLocalAddress()
getLocalAddress
in class DatagramSocket
public int getLocalPort()
getLocalPort
in class DatagramSocket
public SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class DatagramSocket
public SocketAddress getRemoteSocketAddress()
DatagramSocket
will only allow packets from the
remote address that it has, so we consider it connected to this
address.getRemoteSocketAddress
in class DatagramSocket
public InetAddress getInetAddress()
DatagramSocket
will only allow packets from the
remote address that it has, so we consider it connected to this
address.getInetAddress
in class DatagramSocket
public int getPort()
DatagramSocket
will only allow packets from the
remote address that it has, so we consider it connected to this
address.getPort
in class DatagramSocket
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class DatagramSocket
public void receive(DatagramPacket p) throws IOException
receive
in class DatagramSocket
p
- IOException
public void send(DatagramPacket p) throws IOException
send
in class DatagramSocket
IOException
Copyright © 2018. All rights reserved.