public static class UnifiedServerSocket.UnifiedSocket extends Socket
Socket.setTcpNoDelay(boolean)
) does
not trigger mode detection.
Because detecting the mode is a potentially blocking operation, it should not be done in the
accepting thread. Attempting to read from or write to the socket in the accepting thread opens the
caller up to a denial-of-service attack, in which a client connects and then does nothing. This would
prevent any other clients from connecting. Passing the socket returned by accept() to a separate
thread which handles all read and write operations protects against this DoS attack.
Callers can check if the socket has been upgraded to TLS by calling isSecureSocket()
,
and can get the underlying SSLSocket by calling getSslSocket()
.setSocketImplFactory
public boolean isSecureSocket()
public boolean isPlaintextSocket()
public boolean isModeKnown()
public SSLSocket getSslSocket() throws IOException
isSecureSocket()
returned true.IOException
- if detecting the socket mode failsSocketException
- if the mode is PLAINTEXT.public void connect(SocketAddress endpoint) throws IOException
Socket.connect(SocketAddress)
. Calling this method does not trigger mode detection.connect
in class Socket
IOException
public void connect(SocketAddress endpoint, int timeout) throws IOException
Socket.connect(SocketAddress, int)
. Calling this method does not trigger mode detection.connect
in class Socket
IOException
public void bind(SocketAddress bindpoint) throws IOException
Socket.bind(SocketAddress)
. Calling this method does not trigger mode detection.bind
in class Socket
IOException
public InetAddress getInetAddress()
Socket.getInetAddress()
. Calling this method does not trigger mode detection.getInetAddress
in class Socket
public InetAddress getLocalAddress()
Socket.getLocalAddress()
. Calling this method does not trigger mode detection.getLocalAddress
in class Socket
public int getPort()
Socket.getPort()
. Calling this method does not trigger mode detection.public int getLocalPort()
Socket.getLocalPort()
. Calling this method does not trigger mode detection.getLocalPort
in class Socket
public SocketAddress getRemoteSocketAddress()
Socket.getRemoteSocketAddress()
. Calling this method does not trigger mode detection.getRemoteSocketAddress
in class Socket
public SocketAddress getLocalSocketAddress()
Socket.getLocalSocketAddress()
. Calling this method does not trigger mode detection.getLocalSocketAddress
in class Socket
public SocketChannel getChannel()
Socket.getChannel()
. Calling this method does not trigger mode detection.getChannel
in class Socket
public InputStream getInputStream() throws IOException
Socket.getInputStream()
. If the socket mode has not yet been detected, the first read from the
returned input stream will trigger mode detection, which is a potentially blocking operation. This means
the accept() thread should avoid reading from this input stream if possible.getInputStream
in class Socket
IOException
public OutputStream getOutputStream() throws IOException
Socket.getOutputStream()
. If the socket mode has not yet been detected, the first read from the
returned input stream will trigger mode detection, which is a potentially blocking operation. This means
the accept() thread should avoid reading from this input stream if possible.getOutputStream
in class Socket
IOException
public void setTcpNoDelay(boolean on) throws SocketException
Socket.setTcpNoDelay(boolean)
. Calling this method does not trigger mode detection.setTcpNoDelay
in class Socket
SocketException
public boolean getTcpNoDelay() throws SocketException
Socket.getTcpNoDelay()
. Calling this method does not trigger mode detection.getTcpNoDelay
in class Socket
SocketException
public void setSoLinger(boolean on, int linger) throws SocketException
Socket.setSoLinger(boolean, int)
. Calling this method does not trigger mode detection.setSoLinger
in class Socket
SocketException
public int getSoLinger() throws SocketException
Socket.getSoLinger()
. Calling this method does not trigger mode detection.getSoLinger
in class Socket
SocketException
public void sendUrgentData(int data) throws IOException
Socket.sendUrgentData(int)
. Calling this method triggers mode detection, which is a potentially
blocking operation, so it should not be done in the accept() thread.sendUrgentData
in class Socket
IOException
public void setOOBInline(boolean on) throws SocketException
Socket.setOOBInline(boolean)
. Calling this method does not trigger mode detection.setOOBInline
in class Socket
SocketException
public boolean getOOBInline() throws SocketException
Socket.getOOBInline()
. Calling this method does not trigger mode detection.getOOBInline
in class Socket
SocketException
public void setSoTimeout(int timeout) throws SocketException
Socket.setSoTimeout(int)
. Calling this method does not trigger mode detection.setSoTimeout
in class Socket
SocketException
public int getSoTimeout() throws SocketException
Socket.getSoTimeout()
. Calling this method does not trigger mode detection.getSoTimeout
in class Socket
SocketException
public void setSendBufferSize(int size) throws SocketException
Socket.setSendBufferSize(int)
. Calling this method does not trigger mode detection.setSendBufferSize
in class Socket
SocketException
public int getSendBufferSize() throws SocketException
Socket.getSendBufferSize()
. Calling this method does not trigger mode detection.getSendBufferSize
in class Socket
SocketException
public void setReceiveBufferSize(int size) throws SocketException
Socket.setReceiveBufferSize(int)
. Calling this method does not trigger mode detection.setReceiveBufferSize
in class Socket
SocketException
public int getReceiveBufferSize() throws SocketException
Socket.getReceiveBufferSize()
. Calling this method does not trigger mode detection.getReceiveBufferSize
in class Socket
SocketException
public void setKeepAlive(boolean on) throws SocketException
Socket.setKeepAlive(boolean)
. Calling this method does not trigger mode detection.setKeepAlive
in class Socket
SocketException
public boolean getKeepAlive() throws SocketException
Socket.getKeepAlive()
. Calling this method does not trigger mode detection.getKeepAlive
in class Socket
SocketException
public void setTrafficClass(int tc) throws SocketException
Socket.setTrafficClass(int)
. Calling this method does not trigger mode detection.setTrafficClass
in class Socket
SocketException
public int getTrafficClass() throws SocketException
Socket.getTrafficClass()
. Calling this method does not trigger mode detection.getTrafficClass
in class Socket
SocketException
public void setReuseAddress(boolean on) throws SocketException
Socket.setReuseAddress(boolean)
. Calling this method does not trigger mode detection.setReuseAddress
in class Socket
SocketException
public boolean getReuseAddress() throws SocketException
Socket.getReuseAddress()
. Calling this method does not trigger mode detection.getReuseAddress
in class Socket
SocketException
public void close() throws IOException
Socket.close()
. Calling this method does not trigger mode detection.close
in interface Closeable
close
in interface AutoCloseable
close
in class Socket
IOException
public void shutdownInput() throws IOException
Socket.shutdownInput()
. Calling this method does not trigger mode detection.shutdownInput
in class Socket
IOException
public void shutdownOutput() throws IOException
Socket.shutdownOutput()
. Calling this method does not trigger mode detection.shutdownOutput
in class Socket
IOException
public String toString()
Socket.toString()
. Calling this method does not trigger mode detection.public boolean isConnected()
Socket.isConnected()
. Calling this method does not trigger mode detection.isConnected
in class Socket
public boolean isBound()
Socket.isBound()
. Calling this method does not trigger mode detection.public boolean isClosed()
Socket.isClosed()
. Calling this method does not trigger mode detection.public boolean isInputShutdown()
Socket.isInputShutdown()
. Calling this method does not trigger mode detection.isInputShutdown
in class Socket
public boolean isOutputShutdown()
Socket.isOutputShutdown()
. Calling this method does not trigger mode detection.isOutputShutdown
in class Socket
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
Socket.setPerformancePreferences(int, int, int)
. Calling this method does not trigger
mode detection.setPerformancePreferences
in class Socket
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.