public class StandardSocketFactory extends java.lang.Object implements SocketFactory
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
host
The hostname to connect to
|
protected long |
loginTimeoutCheckTimestamp
Time when last Login Timeout check occurred
|
protected int |
loginTimeoutCountdown
The remaining login time in milliseconds.
|
protected int |
port
The port number to connect to
|
protected java.net.Socket |
rawSocket
The underlying TCP/IP socket to use
|
protected int |
socketTimeoutBackup
Backup original Socket timeout to be restored after handshake
|
protected java.net.Socket |
sslSocket
The wrapper for underlying TCP/IP socket
|
Constructor and Description |
---|
StandardSocketFactory() |
Modifier and Type | Method and Description |
---|---|
void |
afterHandshake()
Called by the driver after completing the MySQL protocol handshake and
reading the results of the authentication.
|
void |
beforeHandshake()
Called by the driver before issuing the MySQL protocol handshake.
|
<T extends java.io.Closeable> |
connect(java.lang.String hostname,
int portNumber,
PropertySet pset,
int loginTimeout)
Creates a new socket or channel using the given properties.
|
protected java.net.Socket |
createSocket(PropertySet props)
Create the raw socket.
|
protected int |
getRealTimeout(int expectedTimeout)
Validates the connection/socket timeout that must really be used.
|
<T extends java.io.Closeable> |
performTlsHandshake(SocketConnection socketConnection,
ServerSession serverSession)
If required, called by the driver during MySQL protocol handshake to transform
original socket to SSL socket and perform TLS handshake.
|
protected void |
resetLoginTimeCountdown()
Decrements elapsed time since last reset from login timeout count down.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isLocallyConnected, isLocallyConnected
protected java.lang.String host
protected int port
protected java.net.Socket rawSocket
protected java.net.Socket sslSocket
protected int loginTimeoutCountdown
protected long loginTimeoutCheckTimestamp
protected int socketTimeoutBackup
protected java.net.Socket createSocket(PropertySet props)
props
- properties available to affect behaviour during socket creation.public <T extends java.io.Closeable> T connect(java.lang.String hostname, int portNumber, PropertySet pset, int loginTimeout) throws java.io.IOException
SocketFactory
com.mysql.cj.protocol.StandardSocketFactory
Implementing classes
are responsible for handling synchronization of this method (if needed).connect
in interface SocketFactory
T
- result typehostname
- the hostname passed in the URL. It will be a single
hostname, as the driver parses multi-hosts (for failover) and
calls this method for each host connection attempt.portNumber
- the port number to connect to (if required).pset
- properties passed to the driver via the URL and/or properties
instance.loginTimeout
- login timeout in millisecondsjava.io.IOException
- if an I/O error occurspublic void beforeHandshake() throws java.io.IOException
SocketFactory
beforeHandshake
in interface SocketFactory
java.io.IOException
- if an I/O error occurspublic <T extends java.io.Closeable> T performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession) throws java.io.IOException
SocketFactory
performTlsHandshake
in interface SocketFactory
T
- result typesocketConnection
- current SocketConnectionserverSession
- current ServerSessionjava.io.IOException
- if an I/O error occurspublic void afterHandshake() throws java.io.IOException
SocketFactory
afterHandshake
in interface SocketFactory
java.io.IOException
- if an I/O error occursprotected void resetLoginTimeCountdown() throws java.net.SocketException
java.net.SocketException
- If the login timeout is reached or exceeded.protected int getRealTimeout(int expectedTimeout)
expectedTimeout
- The timeout to validate.