-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public class DelegatingSocket extends Socket
Implements a Socket which delegates its calls to a specific Socket.
-
-
Field Summary
Fields Modifier and Type Field Description protected final SocketChannelchannelprivate InputStreaminputStreamprivate OutputStreamoutputStream
-
Constructor Summary
Constructors Constructor Description DelegatingSocket()Initializes a new DelegatingSocket. DelegatingSocket(InetAddress address, int port)Initializes a new DelegatingSocket. DelegatingSocket(InetAddress address, int port, InetAddress localAddr, int localPort)Initializes a new DelegatingSocket. DelegatingSocket(Proxy proxy)Initializes a new DelegatingSocket. DelegatingSocket(Socket delegate)Initializes a new DelegatingSocket instance which is to delegate (i.e. DelegatingSocket(Socket delegate, SocketChannel channel)Initializes a new DelegatingSocket instance which is to delegate (i.e. DelegatingSocket(String host, int port)Initializes a new DelegatingSocket. DelegatingSocket(String host, int port, InetAddress localAddr, int localPort)Initializes a new DelegatingSocket.
-
Method Summary
Modifier and Type Method Description SocketChannelgetChannel()InputStreamgetInputStream()OutputStreamgetOutputStream()static voidreceiveFromInputStream(DatagramPacket p, InputStream inputStream, InetAddress inetAddress, int port)Receives an RFC4571-formatted frame from inputStream into p, and sets p's port and address to port and inetAddress. voidbind(SocketAddress bindpoint)voidclose()voidconnect(SocketAddress endpoint)voidconnect(SocketAddress endpoint, int timeout)InetAddressgetInetAddress()booleangetKeepAlive()InetAddressgetLocalAddress()intgetLocalPort()SocketAddressgetLocalSocketAddress()booleangetOOBInline()intgetPort()intgetReceiveBufferSize()SocketAddressgetRemoteSocketAddress()booleangetReuseAddress()intgetSendBufferSize()intgetSoLinger()intgetSoTimeout()booleangetTcpNoDelay()intgetTrafficClass()booleanisBound()booleanisClosed()booleanisConnected()booleanisInputShutdown()booleanisOutputShutdown()voidreceive(DatagramPacket p)Receives a datagram packet from this socket. voidsend(DatagramPacket p)Send a datagram packet from this socket. voidsendUrgentData(int data)voidsetKeepAlive(boolean on)voidsetOOBInline(boolean on)voidsetOriginalInputStream(InputStream inputStream)Set original InputStream. voidsetPerformancePreferences(int connectionTime, int latency, int bandwidth)voidsetReceiveBufferSize(int size)voidsetReuseAddress(boolean on)voidsetSendBufferSize(int size)voidsetSoLinger(boolean on, int linger)voidsetSoTimeout(int timeout)voidsetTcpNoDelay(boolean on)voidsetTrafficClass(int tc)voidshutdownInput()voidshutdownOutput()StringtoString()-
-
Constructor Detail
-
DelegatingSocket
DelegatingSocket()
Initializes a new DelegatingSocket.
-
DelegatingSocket
DelegatingSocket(InetAddress address, int port)
Initializes a new DelegatingSocket.- Parameters:
address- ignoredport- ignored
-
DelegatingSocket
DelegatingSocket(InetAddress address, int port, InetAddress localAddr, int localPort)
Initializes a new DelegatingSocket.- Parameters:
address- ignoredport- ignoredlocalAddr- ignoredlocalPort- ignored
-
DelegatingSocket
DelegatingSocket(Proxy proxy)
Initializes a new DelegatingSocket.- Parameters:
proxy- ignored
-
DelegatingSocket
DelegatingSocket(Socket delegate)
Initializes a new DelegatingSocket instance which is to delegate (i.e.- Parameters:
delegate- the Socket the new instance is to delegate to
-
DelegatingSocket
DelegatingSocket(Socket delegate, SocketChannel channel)
Initializes a new DelegatingSocket instance which is to delegate (i.e.- Parameters:
delegate- the Socket the new instance is to delegate tochannel- the SocketChannel to be returned by getChannel.
-
DelegatingSocket
DelegatingSocket(String host, int port)
Initializes a new DelegatingSocket.- Parameters:
host- ignoredport- ignored
-
DelegatingSocket
DelegatingSocket(String host, int port, InetAddress localAddr, int localPort)
Initializes a new DelegatingSocket.- Parameters:
host- ignoredport- ignoredlocalAddr- ignoredlocalPort- ignored
-
-
Method Detail
-
getChannel
SocketChannel getChannel()
-
getInputStream
InputStream getInputStream()
-
getOutputStream
OutputStream getOutputStream()
-
receiveFromInputStream
static void receiveFromInputStream(DatagramPacket p, InputStream inputStream, InetAddress inetAddress, int port)
Receives an RFC4571-formatted frame from inputStream into p, and sets p's port and address to port and inetAddress.
- Parameters:
p- the DatagramPacket into which to place the incoming data.inputStream- The TCP stream to be read.inetAddress- The receiver address (local address) to set to the datagram packet.port- The receiver port (local port) to set to the datagram packet.
-
bind
void bind(SocketAddress bindpoint)
-
close
void close()
-
connect
void connect(SocketAddress endpoint)
-
connect
void connect(SocketAddress endpoint, int timeout)
-
getInetAddress
InetAddress getInetAddress()
-
getKeepAlive
boolean getKeepAlive()
-
getLocalAddress
InetAddress getLocalAddress()
-
getLocalPort
int getLocalPort()
-
getLocalSocketAddress
SocketAddress getLocalSocketAddress()
-
getOOBInline
boolean getOOBInline()
-
getPort
int getPort()
-
getReceiveBufferSize
int getReceiveBufferSize()
-
getRemoteSocketAddress
SocketAddress getRemoteSocketAddress()
-
getReuseAddress
boolean getReuseAddress()
-
getSendBufferSize
int getSendBufferSize()
-
getSoLinger
int getSoLinger()
-
getSoTimeout
int getSoTimeout()
-
getTcpNoDelay
boolean getTcpNoDelay()
-
getTrafficClass
int getTrafficClass()
-
isBound
boolean isBound()
-
isClosed
boolean isClosed()
-
isConnected
boolean isConnected()
-
isInputShutdown
boolean isInputShutdown()
-
isOutputShutdown
boolean isOutputShutdown()
-
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 MultiplexedSockets 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
-
send
void send(DatagramPacket p)
Send a datagram packet from this socket.
- Parameters:
p- DatagramPacket to sent
-
sendUrgentData
void sendUrgentData(int data)
-
setKeepAlive
void setKeepAlive(boolean on)
-
setOOBInline
void setOOBInline(boolean on)
-
setOriginalInputStream
void setOriginalInputStream(InputStream inputStream)
Set original InputStream.
- Parameters:
inputStream- InputStream
-
setPerformancePreferences
void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
-
setReceiveBufferSize
void setReceiveBufferSize(int size)
-
setReuseAddress
void setReuseAddress(boolean on)
-
setSendBufferSize
void setSendBufferSize(int size)
-
setSoLinger
void setSoLinger(boolean on, int linger)
-
setSoTimeout
void setSoTimeout(int timeout)
-
setTcpNoDelay
void setTcpNoDelay(boolean on)
-
setTrafficClass
void setTrafficClass(int tc)
-
shutdownInput
void shutdownInput()
-
shutdownOutput
void shutdownOutput()
-
-
-
-