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().setSocketImplFactorypublic 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 SocketIOExceptionpublic void connect(SocketAddress endpoint, int timeout) throws IOException
Socket.connect(SocketAddress, int). Calling this method does not trigger mode detection.connect in class SocketIOExceptionpublic void bind(SocketAddress bindpoint) throws IOException
Socket.bind(SocketAddress). Calling this method does not trigger mode detection.bind in class SocketIOExceptionpublic InetAddress getInetAddress()
Socket.getInetAddress(). Calling this method does not trigger mode detection.getInetAddress in class Socketpublic InetAddress getLocalAddress()
Socket.getLocalAddress(). Calling this method does not trigger mode detection.getLocalAddress in class Socketpublic 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 Socketpublic SocketAddress getRemoteSocketAddress()
Socket.getRemoteSocketAddress(). Calling this method does not trigger mode detection.getRemoteSocketAddress in class Socketpublic SocketAddress getLocalSocketAddress()
Socket.getLocalSocketAddress(). Calling this method does not trigger mode detection.getLocalSocketAddress in class Socketpublic SocketChannel getChannel()
Socket.getChannel(). Calling this method does not trigger mode detection.getChannel in class Socketpublic 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 SocketIOExceptionpublic 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 SocketIOExceptionpublic void setTcpNoDelay(boolean on)
throws SocketException
Socket.setTcpNoDelay(boolean). Calling this method does not trigger mode detection.setTcpNoDelay in class SocketSocketExceptionpublic boolean getTcpNoDelay()
throws SocketException
Socket.getTcpNoDelay(). Calling this method does not trigger mode detection.getTcpNoDelay in class SocketSocketExceptionpublic void setSoLinger(boolean on,
int linger)
throws SocketException
Socket.setSoLinger(boolean, int). Calling this method does not trigger mode detection.setSoLinger in class SocketSocketExceptionpublic int getSoLinger()
throws SocketException
Socket.getSoLinger(). Calling this method does not trigger mode detection.getSoLinger in class SocketSocketExceptionpublic 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 SocketIOExceptionpublic void setOOBInline(boolean on)
throws SocketException
Socket.setOOBInline(boolean). Calling this method does not trigger mode detection.setOOBInline in class SocketSocketExceptionpublic boolean getOOBInline()
throws SocketException
Socket.getOOBInline(). Calling this method does not trigger mode detection.getOOBInline in class SocketSocketExceptionpublic void setSoTimeout(int timeout)
throws SocketException
Socket.setSoTimeout(int). Calling this method does not trigger mode detection.setSoTimeout in class SocketSocketExceptionpublic int getSoTimeout()
throws SocketException
Socket.getSoTimeout(). Calling this method does not trigger mode detection.getSoTimeout in class SocketSocketExceptionpublic void setSendBufferSize(int size)
throws SocketException
Socket.setSendBufferSize(int). Calling this method does not trigger mode detection.setSendBufferSize in class SocketSocketExceptionpublic int getSendBufferSize()
throws SocketException
Socket.getSendBufferSize(). Calling this method does not trigger mode detection.getSendBufferSize in class SocketSocketExceptionpublic void setReceiveBufferSize(int size)
throws SocketException
Socket.setReceiveBufferSize(int). Calling this method does not trigger mode detection.setReceiveBufferSize in class SocketSocketExceptionpublic int getReceiveBufferSize()
throws SocketException
Socket.getReceiveBufferSize(). Calling this method does not trigger mode detection.getReceiveBufferSize in class SocketSocketExceptionpublic void setKeepAlive(boolean on)
throws SocketException
Socket.setKeepAlive(boolean). Calling this method does not trigger mode detection.setKeepAlive in class SocketSocketExceptionpublic boolean getKeepAlive()
throws SocketException
Socket.getKeepAlive(). Calling this method does not trigger mode detection.getKeepAlive in class SocketSocketExceptionpublic void setTrafficClass(int tc)
throws SocketException
Socket.setTrafficClass(int). Calling this method does not trigger mode detection.setTrafficClass in class SocketSocketExceptionpublic int getTrafficClass()
throws SocketException
Socket.getTrafficClass(). Calling this method does not trigger mode detection.getTrafficClass in class SocketSocketExceptionpublic void setReuseAddress(boolean on)
throws SocketException
Socket.setReuseAddress(boolean). Calling this method does not trigger mode detection.setReuseAddress in class SocketSocketExceptionpublic boolean getReuseAddress()
throws SocketException
Socket.getReuseAddress(). Calling this method does not trigger mode detection.getReuseAddress in class SocketSocketExceptionpublic void close()
throws IOException
Socket.close(). Calling this method does not trigger mode detection.close in interface Closeableclose in interface AutoCloseableclose in class SocketIOExceptionpublic void shutdownInput()
throws IOException
Socket.shutdownInput(). Calling this method does not trigger mode detection.shutdownInput in class SocketIOExceptionpublic void shutdownOutput()
throws IOException
Socket.shutdownOutput(). Calling this method does not trigger mode detection.shutdownOutput in class SocketIOExceptionpublic 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 Socketpublic 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 Socketpublic boolean isOutputShutdown()
Socket.isOutputShutdown(). Calling this method does not trigger mode detection.isOutputShutdown in class Socketpublic void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
Socket.setPerformancePreferences(int, int, int). Calling this method does not trigger
mode detection.setPerformancePreferences in class SocketCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.