Package org.conscrypt
Class SSLSocketWrapper
java.lang.Object
java.net.Socket
javax.net.ssl.SSLSocket
org.conscrypt.SSLSocketImpl
org.conscrypt.SSLSocketWrapper
- All Implemented Interfaces:
Closeable,AutoCloseable
public class SSLSocketWrapper extends SSLSocketImpl
This class wraps the SSL fuctionality over existing conneted socket.
-
Field Summary
Fields inherited from class org.conscrypt.SSLSocketImpl
input, output, recordProtocol, sslParameters -
Constructor Summary
Constructors Modifier Constructor Description protectedSSLSocketWrapper(Socket socket, String host, int port, boolean autoClose, SSLParametersImpl sslParameters) -
Method Summary
Modifier and Type Method Description voidbind(SocketAddress sockaddr)Binds this socket to the given local host address and port specified by the SocketAddresslocalAddr.protected voidcloseTransportLayer()Closes the transport data streams.voidconnect(SocketAddress sockaddr)This method works according to the specification of implemented class.voidconnect(SocketAddress sockaddr, int timeout)This method works according to the specification of implemented class.FileDescriptorgetFileDescriptor$()InetAddressgetInetAddress()Returns the IP address of the target host this socket is connected to, or null if this socket is not yet connected.booleangetKeepAlive()Returns this socket'sSocketOptions.SO_KEEPALIVEsetting.InetAddressgetLocalAddress()Returns the local IP address this socket is bound to, orInetAddress.ANYif the socket is unbound.intgetLocalPort()Returns the local port this socket is bound to, or -1 if the socket is unbound.SocketAddressgetLocalSocketAddress()Returns the local address and port of this socket as a SocketAddress or null if the socket is unbound.booleangetOOBInline()Returns this socket'sSocketOptions.SO_OOBINLINEsetting.intgetPort()Returns the port number of the target host this socket is connected to, or 0 if this socket is not yet connected.intgetReceiveBufferSize()Returns this socket'sreceive buffer size.SocketAddressgetRemoteSocketAddress()Returns the remote address and port of this socket as aSocketAddressor null if the socket is not connected.booleangetReuseAddress()Returns this socket'sSocketOptions.SO_REUSEADDRsetting.intgetSendBufferSize()Returns this socket'ssend buffer size.intgetSoLinger()Returns this socket'slingertimeout in seconds, or -1 for no linger (i.e.intgetSoTimeout()Returns this socket'sreceive timeout.booleangetTcpNoDelay()Returns this socket'sSocketOptions#TCP_NODELAYsetting.intgetTrafficClass()Returns this socket's {@see SocketOptions#IP_TOS} setting.protected voidinitTransportLayer()Initialize the transport data streams.booleanisBound()Returns whether this socket is bound to a local address and port.booleanisClosed()Returns whether this socket is closed.booleanisConnected()Returns whether this socket is connected to a remote host.booleanisInputShutdown()Returns whether the incoming channel of the socket has already been closed.booleanisOutputShutdown()Returns whether the outgoing channel of the socket has already been closed.voidsetKeepAlive(boolean on)Sets this socket'sSocketOptions.SO_KEEPALIVEoption.voidsetReceiveBufferSize(int size)Sets this socket'sreceive buffer size.voidsetReuseAddress(boolean on)Sets this socket'sSocketOptions.SO_REUSEADDRoption.voidsetSendBufferSize(int size)Sets this socket'ssend buffer size.voidsetSoLinger(boolean on, int linger)Sets this socket'slingertimeout in seconds.voidsetSoTimeout(int to)Sets this socket'sread timeoutin milliseconds.voidsetTcpNoDelay(boolean on)Sets this socket'sSocketOptions.TCP_NODELAYoption.voidsetTrafficClass(int tos)Sets this socket'sSocketOptions.IP_TOSvalue for every packet sent by this socket.StringtoString()Returns aStringcontaining a concise, human-readable description of the socket.Methods inherited from class org.conscrypt.SSLSocketImpl
addHandshakeCompletedListener, close, getEnabledCipherSuites, getEnabledProtocols, getEnableSessionCreation, getInputStream, getNeedClientAuth, getOutputStream, getSession, getSupportedCipherSuites, getSupportedProtocols, getUseClientMode, getWantClientAuth, init, needAppData, removeHandshakeCompletedListener, sendUrgentData, setEnabledCipherSuites, setEnabledProtocols, setEnableSessionCreation, setNeedClientAuth, setOOBInline, setUseClientMode, setWantClientAuth, startHandshake, writeAppDataMethods inherited from class javax.net.ssl.SSLSocket
getSSLParameters, setSSLParameters, shutdownInput, shutdownOutputMethods inherited from class java.net.Socket
getChannel, setPerformancePreferences, setSocketImplFactory
-
Constructor Details
-
SSLSocketWrapper
protected SSLSocketWrapper(Socket socket, String host, int port, boolean autoClose, SSLParametersImpl sslParameters) throws IOException- Throws:
IOException
-
-
Method Details
-
initTransportLayer
Description copied from class:SSLSocketImplInitialize the transport data streams.- Overrides:
initTransportLayerin classSSLSocketImpl- Throws:
IOException
-
closeTransportLayer
Description copied from class:SSLSocketImplCloses the transport data streams.- Overrides:
closeTransportLayerin classSSLSocketImpl- Throws:
IOException
-
connect
Description copied from class:SSLSocketImplThis method works according to the specification of implemented class.- Overrides:
connectin classSSLSocketImpl- Parameters:
sockaddr- the address and port of the remote host to connect to.timeout- the timeout value in milliseconds or0for an infinite timeout.- Throws:
IOException- if the socket is already connected or an error occurs while connecting.- See Also:
method documentation for more information
-
connect
Description copied from class:SSLSocketImplThis method works according to the specification of implemented class.- Overrides:
connectin classSSLSocketImpl- Parameters:
sockaddr- the address and port of the remote host to connect to.- Throws:
IOException- if the socket is already connected or an error occurs while connecting.- See Also:
method documentation for more information
-
bind
Description copied from class:SocketBinds this socket to the given local host address and port specified by the SocketAddresslocalAddr. IflocalAddris set tonull, this socket will be bound to an available local address on any free port.- Overrides:
bindin classSocket- Parameters:
sockaddr- the specific address and port on the local machine to bind to.- Throws:
IOException- if the socket is already bound or an error occurs while binding.
-
getRemoteSocketAddress
Description copied from class:SocketReturns the remote address and port of this socket as aSocketAddressor null if the socket is not connected.- Overrides:
getRemoteSocketAddressin classSocket- Returns:
- the remote socket address and port.
-
getLocalSocketAddress
Description copied from class:SocketReturns the local address and port of this socket as a SocketAddress or null if the socket is unbound. This is useful on multihomed hosts.- Overrides:
getLocalSocketAddressin classSocket
-
getLocalAddress
Description copied from class:SocketReturns the local IP address this socket is bound to, orInetAddress.ANYif the socket is unbound.- Overrides:
getLocalAddressin classSocket
-
getInetAddress
Description copied from class:SocketReturns the IP address of the target host this socket is connected to, or null if this socket is not yet connected.- Overrides:
getInetAddressin classSocket
-
toString
Description copied from class:SocketReturns aStringcontaining a concise, human-readable description of the socket. -
setSoLinger
Description copied from class:Socket- Overrides:
setSoLingerin classSocket- Throws:
SocketException
-
setTcpNoDelay
Description copied from class:SocketSets this socket'sSocketOptions.TCP_NODELAYoption.- Overrides:
setTcpNoDelayin classSocket- Throws:
SocketException
-
setReuseAddress
Description copied from class:SocketSets this socket'sSocketOptions.SO_REUSEADDRoption.- Overrides:
setReuseAddressin classSocket- Throws:
SocketException
-
setKeepAlive
Description copied from class:SocketSets this socket'sSocketOptions.SO_KEEPALIVEoption.- Overrides:
setKeepAlivein classSocket- Throws:
SocketException
-
setTrafficClass
Description copied from class:SocketSets this socket'sSocketOptions.IP_TOSvalue for every packet sent by this socket.- Overrides:
setTrafficClassin classSocket- Throws:
SocketException
-
setSoTimeout
Description copied from class:SocketSets this socket'sread timeoutin milliseconds. Use 0 for no timeout. To take effect, this option must be set before the blocking method was called.- Overrides:
setSoTimeoutin classSocket- Throws:
SocketException
-
setSendBufferSize
Description copied from class:SocketSets this socket'ssend buffer size.- Overrides:
setSendBufferSizein classSocket- Throws:
SocketException
-
setReceiveBufferSize
Description copied from class:SocketSets this socket'sreceive buffer size.- Overrides:
setReceiveBufferSizein classSocket- Throws:
SocketException
-
getTcpNoDelay
Description copied from class:SocketReturns this socket'sSocketOptions#TCP_NODELAYsetting.- Overrides:
getTcpNoDelayin classSocket- Throws:
SocketException
-
getReuseAddress
Description copied from class:SocketReturns this socket'sSocketOptions.SO_REUSEADDRsetting.- Overrides:
getReuseAddressin classSocket- Throws:
SocketException
-
getOOBInline
Description copied from class:SocketReturns this socket'sSocketOptions.SO_OOBINLINEsetting.- Overrides:
getOOBInlinein classSocket- Throws:
SocketException
-
getKeepAlive
Description copied from class:SocketReturns this socket'sSocketOptions.SO_KEEPALIVEsetting.- Overrides:
getKeepAlivein classSocket- Throws:
SocketException
-
getTrafficClass
Description copied from class:SocketReturns this socket's {@see SocketOptions#IP_TOS} setting.- Overrides:
getTrafficClassin classSocket- Throws:
SocketException
-
getSoTimeout
Description copied from class:SocketReturns this socket'sreceive timeout.- Overrides:
getSoTimeoutin classSocket- Throws:
SocketException
-
getSoLinger
Description copied from class:SocketReturns this socket'slingertimeout in seconds, or -1 for no linger (i.e.closewill return immediately).- Overrides:
getSoLingerin classSocket- Throws:
SocketException
-
getSendBufferSize
Description copied from class:SocketReturns this socket'ssend buffer size.- Overrides:
getSendBufferSizein classSocket- Throws:
SocketException
-
getReceiveBufferSize
Description copied from class:SocketReturns this socket'sreceive buffer size.- Overrides:
getReceiveBufferSizein classSocket- Throws:
SocketException
-
isConnected
public boolean isConnected()Description copied from class:SocketReturns whether this socket is connected to a remote host.- Overrides:
isConnectedin classSocket- Returns:
trueif the socket is connected,falseotherwise.
-
isClosed
public boolean isClosed()Description copied from class:SocketReturns whether this socket is closed. -
isBound
public boolean isBound()Description copied from class:SocketReturns whether this socket is bound to a local address and port. -
isOutputShutdown
public boolean isOutputShutdown()Description copied from class:SocketReturns whether the outgoing channel of the socket has already been closed.- Overrides:
isOutputShutdownin classSocket- Returns:
trueif writing to this socket is not possible anymore,falseotherwise.
-
isInputShutdown
public boolean isInputShutdown()Description copied from class:SocketReturns whether the incoming channel of the socket has already been closed.- Overrides:
isInputShutdownin classSocket- Returns:
trueif reading from this socket is not possible anymore,falseotherwise.
-
getPort
public int getPort()Description copied from class:SocketReturns the port number of the target host this socket is connected to, or 0 if this socket is not yet connected. -
getLocalPort
public int getLocalPort()Description copied from class:SocketReturns the local port this socket is bound to, or -1 if the socket is unbound.- Overrides:
getLocalPortin classSocket
-
getFileDescriptor$
- Overrides:
getFileDescriptor$in classSocket
-