public class MultiplexingSocket extends DelegatingSocket
Modifier and Type | Field and Description |
---|---|
private InputStream |
inputStream
Custom InputStream for this Socket.
|
private static Logger |
logger
The Logger used by the MultiplexingSocket class and its
instances for logging output.
|
private MultiplexingXXXSocketSupport<MultiplexedSocket> |
multiplexingXXXSocketSupport
The
MultiplexingXXXSocketSupport which implements functionality
common to TCP and UDP sockets in order to facilitate implementers such as
this instance. |
private TCPOutputStream |
outputStream
Custom OutputStream for this Socket.
|
private List<DatagramPacket> |
received
The list of DatagramPackets to be received through this
Socket i.e.
|
private int |
soTimeout
Buffer variable for storing the SO_TIMEOUT value set by the last
setSoTimeout() call.
|
channel, delegate
Modifier | Constructor and Description |
---|---|
|
MultiplexingSocket()
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(InetAddress address,
int port)
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(InetAddress address,
int port,
InetAddress localAddr,
int localPort)
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(Proxy proxy)
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(Socket socket)
Initializes a new MultiplexingSocket instance.
|
protected |
MultiplexingSocket(SocketImpl impl)
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(String host,
int port)
Initializes a new MultiplexingSocket instance.
|
|
MultiplexingSocket(String host,
int port,
InetAddress localAddr,
int localPort)
Initializes a new MultiplexingSocket instance.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
close(MultiplexedSocket multiplexed)
Closes a specific MultiplexedSocket which filters
DatagramPackets away from this Socket.
|
InputStream |
getInputStream() |
InputStream |
getOriginalInputStream()
Get original InputStream.
|
OutputStream |
getOriginalOutputStream()
Get original OutputStream.
|
OutputStream |
getOutputStream() |
MultiplexedSocket |
getSocket(DatagramPacketFilter filter)
Gets a MultiplexedDatagramSocket which filters
DatagramPackets away from this DatagramSocket using a
specific DatagramPacketFilter.
|
int |
getSoTimeout() |
private void |
multiplexingXXXSocketSupportDoReceive(DatagramPacket p)
Implements
MultiplexingXXXSocketSupport.doReceive(DatagramPacket)
on behalf of multiplexingXXXSocketSupport . |
private void |
multiplexingXXXSocketSupportDoSetReceiveBufferSize(int receiveBufferSize)
Implements
MultiplexingXXXSocketSupport.doSetReceiveBufferSize(int) on
behalf of multiplexingXXXSocketSupport . |
void |
receive(DatagramPacket p)
Receives a datagram packet from this socket.
|
(package private) void |
receive(MultiplexedSocket multiplexed,
DatagramPacket p)
Receives a DatagramPacket from this Socket upon
request from a specific MultiplexedSocket.
|
void |
setSoTimeout(int timeout) |
bind, close, connect, connect, getChannel, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, receiveFromInputStream, send, sendUrgentData, setKeepAlive, setOOBInline, setOriginalInputStream, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
setSocketImplFactory
private static final Logger logger
private final InputStream inputStream
private final MultiplexingXXXSocketSupport<MultiplexedSocket> multiplexingXXXSocketSupport
MultiplexingXXXSocketSupport
which implements functionality
common to TCP and UDP sockets in order to facilitate implementers such as
this instance.private TCPOutputStream outputStream
private final List<DatagramPacket> received
#sockets
at the time of the reading from the network.private int soTimeout
public MultiplexingSocket()
Socket.Socket()
public MultiplexingSocket(InetAddress address, int port)
address
- not usedport
- not usedSocket.Socket(InetAddress, int)
public MultiplexingSocket(InetAddress address, int port, InetAddress localAddr, int localPort)
address
- not usedport
- not usedlocalAddr
- not usedlocalPort
- not usedSocket.Socket(InetAddress, int, InetAddress, int)
public MultiplexingSocket(Proxy proxy)
proxy
- not usedSocket.Socket(Proxy)
public MultiplexingSocket(Socket socket)
socket
- delegate socketprotected MultiplexingSocket(SocketImpl impl)
impl
- not usedSocket.Socket(SocketImpl)
public MultiplexingSocket(String host, int port)
host
- not usedport
- not usedSocket.Socket(String, int)
public MultiplexingSocket(String host, int port, InetAddress localAddr, int localPort)
host
- not usedport
- not usedlocalAddr
- not usedlocalPort
- not usedSocket.Socket(String, int, InetAddress, int)
void close(MultiplexedSocket multiplexed)
multiplexed
- the MultiplexedSocket to closepublic InputStream getInputStream() throws IOException
getInputStream
in class DelegatingSocket
IOException
public InputStream getOriginalInputStream() throws IOException
IOException
- if something goes wrongpublic OutputStream getOriginalOutputStream() throws IOException
IOException
- if something goes wrongpublic OutputStream getOutputStream() throws IOException
getOutputStream
in class DelegatingSocket
IOException
public MultiplexedSocket getSocket(DatagramPacketFilter filter) throws SocketException
filter
- the DatagramPacketFilter to get a
MultiplexedDatagramSocket forSocketException
- if creating the
MultiplexedDatagramSocket for the specified filter
failspublic int getSoTimeout()
getSoTimeout
in class DelegatingSocket
private void multiplexingXXXSocketSupportDoReceive(DatagramPacket p) throws IOException
MultiplexingXXXSocketSupport.doReceive(DatagramPacket)
on behalf of multiplexingXXXSocketSupport
. Receives a
DatagramPacket
from this socket.p
- the DatagramPacket
into which to place the incoming dataIOException
- if an I/O error occursprivate void multiplexingXXXSocketSupportDoSetReceiveBufferSize(int receiveBufferSize) throws SocketException
MultiplexingXXXSocketSupport.doSetReceiveBufferSize(int)
on
behalf of multiplexingXXXSocketSupport
. Sets the
SO_RCVBUF
option to the specified value for this
DatagramSocket
. The SO_RCVBUF
option is used by the
network implementation as a hint to size the underlying network I/O
buffers. The SO_RCVBUF
setting may also be used by the network
implementation to determine the maximum size of the packet that can be
received on this socket.receiveBufferSize
- the size to which to set the receive buffer sizeSocketException
- if there is an error in the underlying protocol,
such as a TCP errorpublic 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.
receive
in class DelegatingSocket
p
- the DatagramPacket into which to place the incoming
dataIOException
- if an I/O error occursDelegatingSocket.receive(DatagramPacket)
void receive(MultiplexedSocket multiplexed, DatagramPacket p) throws IOException
multiplexed
- the MultiplexedSocket which requests
the receipt of a DatagramPacket from the networkp
- the DatagramPacket to receive the data from the networkIOException
- if an I/O error occurspublic void setSoTimeout(int timeout) throws SocketException
setSoTimeout
in class DelegatingSocket
SocketException
Copyright © 2018. All rights reserved.