okhttp / okhttp3 / ConnectionPool

ConnectionPool

class ConnectionPool

Manages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that share the same Address may share a Connection. This class implements the policy of which connections to keep open for future use.

Constructors

<init>

ConnectionPool()ConnectionPool(maxIdleConnections: Int, keepAliveDuration: Long, timeUnit: TimeUnit)

Create a new connection pool with tuning parameters appropriate for a single-user application. The tuning parameters in this pool are subject to change in future OkHttp releases. Currently this pool holds up to 5 idle connections which will be evicted after 5 minutes of inactivity.

Functions

connectionCount

fun connectionCount(): Int

Returns total number of connections in the pool.

evictAll

fun evictAll(): Unit

Close and remove all idle connections in the pool.

idleConnectionCount

fun idleConnectionCount(): Int

Returns the number of idle connections in the pool.