Skip to content

Commit aafd20d

Browse files
committed
Documentation for how all connectors implement ConnectorInterface
1 parent cf56ed9 commit aafd20d

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ $promise->cancel();
7676

7777
### Async TCP/IP connections
7878

79-
The `React\SocketClient\TcpConnector` provides a single promise-based
80-
`create($ip, $port)` method which resolves as soon as the connection
81-
succeeds or fails.
79+
The `React\SocketClient\TcpConnector` class implements the
80+
[`ConnectorInterface`](#connectorinterface) and allows you to create plaintext
81+
TCP/IP connections to any IP-port-combination:
8282

8383
```php
8484
$tcpConnector = new React\SocketClient\TcpConnector($loop);
@@ -115,17 +115,18 @@ $tcpConnector = new React\SocketClient\TcpConnector($loop, array(
115115
));
116116
```
117117

118-
Note that this class only allows you to connect to IP/port combinations.
119-
If you want to connect to hostname/port combinations, see also the following chapter.
118+
Note that this class only allows you to connect to IP-port-combinations.
119+
If you want to connect to hostname-port-combinations, see also the following chapter.
120120

121121
### DNS resolution
122122

123-
The `DnsConnector` class decorates a given `TcpConnector` instance by first
124-
looking up the given domain name and then establishing the underlying TCP/IP
125-
connection to the resolved IP address.
123+
The `DnsConnector` class implements the
124+
[`ConnectorInterface`](#connectorinterface) and allows you to create plaintext
125+
TCP/IP connections to any hostname-port-combination.
126126

127-
It provides the same promise-based `create($host, $port)` method which resolves with
128-
a `Stream` instance that can be used just like above.
127+
It does so by decorating a given `TcpConnector` instance so that it first
128+
looks up the given domain name via DNS (if applicable) and then establishes the
129+
underlying TCP/IP connection to the resolved target IP address.
129130

130131
Make sure to set up your DNS resolver and underlying TCP connector like this:
131132

@@ -168,11 +169,13 @@ $connector->create('www.google.com', 80)->then($callback);
168169

169170
### Async SSL/TLS connections
170171

171-
The `SecureConnector` class decorates a given `Connector` instance by enabling
172-
SSL/TLS encryption as soon as the raw TCP/IP connection succeeds.
172+
The `SecureConnector` class implements the
173+
[`ConnectorInterface`](#connectorinterface) and allows you to create secure
174+
TLS (formerly known as SSL) connections to any hostname-port-combination.
173175

174-
It provides the same promise- based `create($host, $port)` method which resolves with
175-
a `Stream` instance that can be used just like any non-encrypted stream:
176+
It does so by decorating a given `DnsConnector` instance so that it first
177+
creates a plaintext TCP/IP connection and then enables TLS encryption on this
178+
stream.
176179

177180
```php
178181
$secureConnector = new React\SocketClient\SecureConnector($dnsConnector, $loop);
@@ -219,8 +222,12 @@ stream resources will use a single, shared *default context* resource otherwise.
219222

220223
### Connection timeouts
221224

222-
The `TimeoutConnector` class decorates any given `Connector` instance.
223-
It provides the same `create()` method, but will automatically reject the
225+
The `TimeoutConnector` class implements the
226+
[`ConnectorInterface`](#connectorinterface) and allows you to add timeout
227+
handling to any existing connector instance.
228+
229+
It does so by decorating any given [`ConnectorInterface`](#connectorinterface)
230+
instance and starting a timer that will automatically reject and abort any
224231
underlying connection attempt if it takes too long.
225232

226233
```php
@@ -246,8 +253,9 @@ attempt, abort the timer and reject the resulting promise.
246253

247254
### Unix domain sockets
248255

249-
Similarly, the `UnixConnector` class can be used to connect to Unix domain socket (UDS)
250-
paths like this:
256+
The `UnixConnector` class implements the
257+
[`ConnectorInterface`](#connectorinterface) and allows you to connect to
258+
Unix domain socket (UDS) paths like this:
251259

252260
```php
253261
$connector = new React\SocketClient\UnixConnector($loop);

0 commit comments

Comments
 (0)