|
2 | 2 |
|
3 | 3 | [](http://travis-ci.org/reactphp/socket-client) [](https://codeclimate.com/github/reactphp/socket-client)
|
4 | 4 |
|
5 |
| -Async Connector to open TCP/IP and SSL/TLS based connections. |
| 5 | +Async, streaming plaintext TCP/IP and secure TLS based connections for [ReactPHP](https://reactphp.org/) |
6 | 6 |
|
7 |
| -> The master branch contains the code for the upcoming 0.6 release. |
8 |
| -For the code of the current stable 0.5.x release, checkout the |
9 |
| -[0.5 branch](https://github.com/reactphp/socket-client/tree/0.5). |
10 |
| - |
11 |
| -## Introduction |
12 |
| - |
13 |
| -Think of this library as an async version of |
| 7 | +You can think of this library as an async version of |
14 | 8 | [`fsockopen()`](http://www.php.net/function.fsockopen) or
|
15 | 9 | [`stream_socket_client()`](http://php.net/function.stream-socket-client).
|
16 |
| - |
17 |
| -Before you can actually transmit and receive data to/from a remote server, you |
18 |
| -have to establish a connection to the remote end. Establishing this connection |
19 |
| -through the internet/network takes some time as it requires several steps in |
20 |
| -order to complete: |
21 |
| - |
22 |
| -1. Resolve remote target hostname via DNS (+cache) |
23 |
| -2. Complete TCP handshake (2 roundtrips) with remote target IP:port |
24 |
| -3. Optionally enable SSL/TLS on the new resulting connection |
| 10 | +If you want to transmit and receive data to/from a remote server, you first |
| 11 | +have to establish a connection to the remote end. |
| 12 | +Establishing this connection through the internet/network may take some time |
| 13 | +as it requires several steps (such as resolving target hostname, completing |
| 14 | +TCP/IP handshake and enabling TLS) in order to complete. |
| 15 | +This component provides an async version of all this so you can establish and |
| 16 | +handle multiple connections without blocking. |
| 17 | + |
| 18 | +**Table of Contents** |
| 19 | + |
| 20 | +* [Usage](#usage) |
| 21 | + * [ConnectorInterface](#connectorinterface) |
| 22 | + * [connect()](#connect) |
| 23 | + * [ConnectionInterface](#connectioninterface) |
| 24 | + * [getRemoteAddress()](#getremoteaddress) |
| 25 | + * [getLocalAddress()](#getlocaladdress) |
| 26 | + * [Plaintext TCP/IP connections](#plaintext-tcpip-connections) |
| 27 | + * [DNS resolution](#dns-resolution) |
| 28 | + * [Secure TLS connections](#secure-tls-connections) |
| 29 | + * [Connection timeout](#connection-timeouts) |
| 30 | + * [Unix domain sockets](#unix-domain-sockets) |
| 31 | +* [Install](#install) |
| 32 | +* [Tests](#tests) |
| 33 | +* [License](#license) |
25 | 34 |
|
26 | 35 | ## Usage
|
27 | 36 |
|
@@ -170,7 +179,7 @@ If your system has multiple interfaces (e.g. a WAN and a LAN interface),
|
170 | 179 | you can use this method to find out which interface was actually
|
171 | 180 | used for this connection.
|
172 | 181 |
|
173 |
| -### Async TCP/IP connections |
| 182 | +### Plaintext TCP/IP connections |
174 | 183 |
|
175 | 184 | The `React\SocketClient\TcpConnector` class implements the
|
176 | 185 | [`ConnectorInterface`](#connectorinterface) and allows you to create plaintext
|
@@ -271,7 +280,7 @@ $connector = new React\SocketClient\Connector($loop, $dns);
|
271 | 280 | $connector->connect('www.google.com:80')->then($callback);
|
272 | 281 | ```
|
273 | 282 |
|
274 |
| -### Async SSL/TLS connections |
| 283 | +### Secure TLS connections |
275 | 284 |
|
276 | 285 | The `SecureConnector` class implements the
|
277 | 286 | [`ConnectorInterface`](#connectorinterface) and allows you to create secure
|
@@ -383,15 +392,26 @@ The recommended way to install this library is [through Composer](http://getcomp
|
383 | 392 | This will install the latest supported version:
|
384 | 393 |
|
385 | 394 | ```bash
|
386 |
| -$ composer require react/socket-client:^0.5.3 |
| 395 | +$ composer require react/socket-client:^0.6 |
387 | 396 | ```
|
388 | 397 |
|
389 | 398 | More details about version upgrades can be found in the [CHANGELOG](CHANGELOG.md).
|
390 | 399 |
|
391 | 400 | ## Tests
|
392 | 401 |
|
393 |
| -To run the test suite, you need PHPUnit. Go to the project root and run: |
| 402 | +To run the test suite, you first need to clone this repo and then install all |
| 403 | +dependencies [through Composer](http://getcomposer.org): |
| 404 | + |
| 405 | +```bash |
| 406 | +$ composer install |
| 407 | +``` |
| 408 | + |
| 409 | +To run the test suite, go to the project root and run: |
394 | 410 |
|
395 | 411 | ```bash
|
396 |
| -$ phpunit |
| 412 | +$ php vendor/bin/phpunit |
397 | 413 | ```
|
| 414 | + |
| 415 | +## License |
| 416 | + |
| 417 | +MIT, see [LICENSE file](LICENSE). |
0 commit comments