-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public class MultiplexingSocket extends DelegatingSocket
Represents a Socket which allows filtering DatagramPackets it reads from the network using DatagramPacketFilters so that the DatagramPackets do not get received through it but through associated MultiplexedSockets.
-
-
Field Summary
Fields Modifier and Type Field Description private final InputStreaminputStreamprivate intsoTimeout
-
Constructor Summary
Constructors Constructor 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. MultiplexingSocket(String host, int port)Initializes a new MultiplexingSocket instance. MultiplexingSocket(String host, int port, InetAddress localAddr, int localPort)Initializes a new MultiplexingSocket instance.
-
Method Summary
Modifier and Type Method Description InputStreamgetInputStream()intgetSoTimeout()voidsetSoTimeout(int timeout)InputStreamgetOriginalInputStream()Get original InputStream. OutputStreamgetOriginalOutputStream()Get original OutputStream. MultiplexedSocketgetSocket(DatagramPacketFilter filter)Gets a MultiplexedDatagramSocket which filters DatagramPackets away from this DatagramSocket using a specific DatagramPacketFilter. voidreceive(DatagramPacket p)Receives a datagram packet from this socket. -
Methods inherited from class org.ice4j.socket.DelegatingSocket
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 -
Methods inherited from class java.net.Socket
bind, close, connect, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOption, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setSoTimeout, setSocketImplFactory, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, supportedOptions, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MultiplexingSocket
MultiplexingSocket()
Initializes a new MultiplexingSocket instance.
-
MultiplexingSocket
MultiplexingSocket(InetAddress address, int port)
Initializes a new MultiplexingSocket instance.- Parameters:
address- not usedport- not used
-
MultiplexingSocket
MultiplexingSocket(InetAddress address, int port, InetAddress localAddr, int localPort)
Initializes a new MultiplexingSocket instance.- Parameters:
address- not usedport- not usedlocalAddr- not usedlocalPort- not used
-
MultiplexingSocket
MultiplexingSocket(Proxy proxy)
Initializes a new MultiplexingSocket instance.- Parameters:
proxy- not used
-
MultiplexingSocket
MultiplexingSocket(Socket socket)
Initializes a new MultiplexingSocket instance.- Parameters:
socket- delegate socket
-
MultiplexingSocket
MultiplexingSocket(String host, int port)
Initializes a new MultiplexingSocket instance.- Parameters:
host- not usedport- not used
-
MultiplexingSocket
MultiplexingSocket(String host, int port, InetAddress localAddr, int localPort)
Initializes a new MultiplexingSocket instance.- Parameters:
host- not usedport- not usedlocalAddr- not usedlocalPort- not used
-
-
Method Detail
-
getInputStream
InputStream getInputStream()
-
getSoTimeout
int getSoTimeout()
-
setSoTimeout
void setSoTimeout(int timeout)
-
getOriginalInputStream
InputStream getOriginalInputStream()
Get original InputStream.
-
getOriginalOutputStream
OutputStream getOriginalOutputStream()
Get original OutputStream.
-
getSocket
MultiplexedSocket getSocket(DatagramPacketFilter filter)
Gets a MultiplexedDatagramSocket which filters DatagramPackets away from this DatagramSocket using a specific DatagramPacketFilter. If such a MultiplexedDatagramSocket does not exist in this instance, it is created.
- Parameters:
filter- the DatagramPacketFilter to get a MultiplexedDatagramSocket for
-
receive
void receive(DatagramPacket p)
Receives a datagram packet from this socket. The DatagramPackets returned by this method do not match any of the DatagramPacketFilters of the MultiplexedDatagramSockets associated with this instance at the time of their receipt. When this method returns, the DatagramPacket's buffer is filled with the data received. The datagram packet also contains the sender's IP address, and the port number on the sender's machine.
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.
- Parameters:
p- the DatagramPacket into which to place the incoming data
-
-
-
-