okhttp / okhttp3 / OkHttpClient / Builder / socketFactory

socketFactory

fun socketFactory(socketFactory: SocketFactory): OkHttpClient.Builder

Sets the socket factory used to create connections. OkHttp only uses the parameterless SocketFactory.createSocket method to create unconnected sockets. Overriding this method, e. g., allows the socket to be bound to a specific local address.

If unset, the system-wide default socket factory will be used.