public class IceTcpSocketWrapper extends IceSocketWrapper
Modifier and Type | Field and Description |
---|---|
private InputStream |
inputStream
InputStream for this socket.
|
private OutputStream |
outputStream
OutputStream for this socket.
|
private Socket |
socket
Delegate TCP Socket.
|
private DelegatingSocket |
socketAsDelegatingSocket
A DelegatingSocket view of
socket if the latter
implements the former; otherwise, null. |
Constructor and Description |
---|
IceTcpSocketWrapper(Socket delegate)
Constructor.
|
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 final InputStream inputStream
private final OutputStream outputStream
private final Socket socket
private final DelegatingSocket socketAsDelegatingSocket
socket
if the latter
implements the former; otherwise, null.public IceTcpSocketWrapper(Socket delegate) throws IOException
delegate
- delegate SocketIOException
- if something goes wrong during initializationpublic 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
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.