# Class SocketFactory (1.15.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.15.0 (latest)](https://docs.cloud.google.com/java/docs/reference/jdbc-socket-factory-parent/latest/com.google.cloud.sql.mysql.SocketFactory)
- [1.14.1](https://docs.cloud.google.com/java/docs/reference/jdbc-socket-factory-parent/1.14.1/com.google.cloud.sql.mysql.SocketFactory)

    public class SocketFactory implements SocketFactory

A MySQL SocketFactory that establishes a secure connection to a Cloud SQL instance using
ephemeral certificates.

The heavy lifting is done by the singleton [InternalConnectorRegistry](https://docs.cloud.google.com/java/docs/reference/jdbc-socket-factory-parent/latest/com.google.cloud.sql.core.InternalConnectorRegistry) class.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> SocketFactory

## Implements

com.mysql.cj.protocol.SocketFactory

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### SocketFactory()

    public SocketFactory()

## Methods

### \<T\>connect(String host, int portNumber, PropertySet props, int loginTimeout)

    public T <T>connect(String host, int portNumber, PropertySet props, int loginTimeout)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `host` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `portNumber` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `props` | `com.mysql.cj.conf.PropertySet` |
| `loginTimeout` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### \<T\>connect(String host, int portNumber, Properties props, int loginTimeout)

    public T <T>connect(String host, int portNumber, Properties props, int loginTimeout)

Implements the interface for com.mysql.cj.protocol.SocketFactory for mysql-connector-java prior
to version 8.0.13. This change is required for backwards compatibility.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `host` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `portNumber` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `props` | `https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html` |
| `loginTimeout` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### \<T\>performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession)

    public T <T>performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `socketConnection` | `com.mysql.cj.protocol.SocketConnection` |
| `serverSession` | `com.mysql.cj.protocol.ServerSession` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### afterHandshake()

    public void afterHandshake()

### beforeHandshake()

    public void beforeHandshake()