@@ -340,6 +340,44 @@ $connector->connect('tls://localhost:443')->then(function (ConnectionInterface $
340340 about [ socket context options] ( http://php.net/manual/en/context.socket.php )
341341 and [ SSL context options] ( http://php.net/manual/en/context.ssl.php ) .
342342
343+ Advanced: By default, the ` Connector ` supports the ` tcp:// ` , ` tls:// ` and
344+ ` unix:// ` URI schemes.
345+ For this, it sets up the required connector classes automatically.
346+ If you want to explicitly pass custom connectors for any of these, you can simply
347+ pass an instance implementing the ` ConnectorInterface ` like this:
348+
349+ ``` php
350+ $dnsResolverFactory = new React\Dns\Resolver\Factory();
351+ $resolver = $dnsResolverFactory->createCached('127.0.1.1', $loop);
352+ $tcp = new DnsConnector(new TcpConnector($loop), $resolver);
353+
354+ $tls = new SecureConnector($tcp, $loop);
355+
356+ $unix = new UnixConnector($loop);
357+
358+ $connector = new Connector($loop, array(
359+ 'tcp' => $tcp,
360+ 'dns' => false,
361+ 'tls' => $tls,
362+ 'unix' => $unix,
363+ ));
364+
365+ $connector->connect('google.com:80')->then(function (ConnectionInterface $connection) {
366+ $connection->write('...');
367+ $connection->end();
368+ });
369+ ```
370+
371+ > Internally, the ` tcp:// ` connector will always be wrapped by the DNS resolver,
372+ unless you disable DNS like in the above example. In this case, the ` tcp:// `
373+ connector receives the actual hostname instead of only the resolved IP address
374+ and is thus responsible for performing the lookup.
375+ Internally, the automatically created ` tls:// ` connector will always wrap the
376+ underlying ` tcp:// ` connector for establishing the underlying plaintext
377+ TCP/IP connection before enabling secure TLS mode. If you want to use a custom
378+ underlying ` tcp:// ` connector for secure TLS connections only, you may
379+ explicitly pass a ` tls:// ` connector like above instead.
380+
343381## Advanced Usage
344382
345383### TcpConnector
0 commit comments