Class ClientConnector

java.lang.Object
All Implemented Interfaces:
Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle

@ManagedObject public class ClientConnector extends ContainerLifeCycle

The client-side component that connects to server sockets.

ClientConnector delegates the handling of SocketChannels to a SelectorManager, and centralizes the configuration of necessary components such as the executor, the scheduler, etc.

ClientConnector offers a low-level API that can be used to connect SocketChannels to listening servers via the connect(SocketAddress, Map) method.

However, a ClientConnector instance is typically just configured and then passed to an HttpClient transport, so that applications can use high-level APIs to make HTTP requests to servers:

 // Create a ClientConnector instance.
 ClientConnector connector = new ClientConnector();

 // Configure the ClientConnector.
 connector.setSelectors(1);
 connector.setSslContextFactory(new SslContextFactory.Client());

 // Pass it to the HttpClient transport.
 HttpClientTransport transport = new HttpClientTransportDynamic(connector);
 HttpClient httpClient = new HttpClient(transport);
 httpClient.start();