protected static class AbstractTcpListener.PushBackIceSocketWrapper extends IceSocketWrapper
receive(DatagramPacket)
.Modifier and Type | Field and Description |
---|---|
private DatagramPacket |
datagramPacket
The DatagramPacket which will be used on the first call to
receive(DatagramPacket) . |
private IceSocketWrapper |
wrapped
The IceSocketWrapper that this instance wraps around.
|
Constructor and Description |
---|
PushBackIceSocketWrapper(IceSocketWrapper wrappedWrapper,
DatagramPacket datagramPacket)
Initializes a new PushBackIceSocketWrapper instance that
wraps around wrappedWrapper and reads from
datagramSocket on the first call to
receive(DatagramPacket) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this socket.
|
InetAddress |
getLocalAddress()
Get local address.
|
int |
getLocalPort()
Get local port.
|
SocketAddress |
getLocalSocketAddress()
Get socket address.
|
Socket |
getTCPSocket()
Returns Socket object if the delegate socket is a TCP one, null
otherwise.
|
DatagramSocket |
getUDPSocket()
Returns DatagramSocket object if the delegate socket is a UDP one, null
otherwise.
|
void |
receive(DatagramPacket p)
Receives a DatagramPacket from this socket.
|
void |
send(DatagramPacket p)
Sends a DatagramPacket from this socket
It is a utility method to provide a common way to send for both
UDP and TCP socket.
|
private DatagramPacket datagramPacket
receive(DatagramPacket)
.private final IceSocketWrapper wrapped
public PushBackIceSocketWrapper(IceSocketWrapper wrappedWrapper, DatagramPacket datagramPacket)
receive(DatagramPacket)
wrappedWrapper
- the IceSocketWrapper instance that we
wrap around.datagramPacket
- the DatagramPacket which will be used
on the first call to receive(DatagramPacket)
public void close()
close
in class IceSocketWrapper
public InetAddress getLocalAddress()
getLocalAddress
in class IceSocketWrapper
public int getLocalPort()
getLocalPort
in class IceSocketWrapper
public SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class IceSocketWrapper
public Socket getTCPSocket()
getTCPSocket
in class IceSocketWrapper
public DatagramSocket getUDPSocket()
getUDPSocket
in class IceSocketWrapper
public void receive(DatagramPacket p) throws IOException
datagramPacket
, on subsequent calls delegates to
wrapped
.receive
in class IceSocketWrapper
p
- DatagramPacketIOException
- if something goes wrongpublic void send(DatagramPacket p) throws IOException
send
in class IceSocketWrapper
p
- DatagramPacket to sendIOException
- if something goes wrongCopyright © 2018. All rights reserved.