PHPackages                             react/socket-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. react/socket-client

Abandoned → [react/socket](/?search=react%2Fsocket)Library[Queues &amp; Workers](/categories/queues)

react/socket-client
===================

Async, streaming plaintext TCP/IP and secure TLS based connections for ReactPHP

v0.7.0(9y ago)1034.3M↓39.9%2420MITPHPPHP &gt;=5.3.0

Since Apr 14Pushed 9y ago12 watchersCompare

[ Source](https://github.com/reactphp-legacy/socket-client)[ Packagist](https://packagist.org/packages/react/socket-client)[ RSS](/packages/react-socket-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (9)Versions (22)Used By (20)

Maintenance Mode
================

[](#maintenance-mode)

This component has now been merged into the [Socket component](https://github.com/reactphp/socket) and only exists for BC reasons.

```
$ composer require react/socket
```

If you've previously used the SocketClient component to establish outgoing client connections, upgrading should take no longer than a few minutes. All classes have been merged as-is from the latest `v0.7.0` release with no other changes, so you can simply update your code to use the updated namespace like this:

```
// old from SocketClient component and namespace
$connector = new React\SocketClient\Connector($loop);
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
    $connection->write('…');
});

// new
$connector = new React\Socket\Connector($loop);
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
    $connection->write('…');
});
```

See  for more details.

The below documentation applies to the last release of this component. Further development will take place in the updated [Socket component](https://github.com/reactphp/socket), so you're highly recommended to upgrade as soon as possible.

Legacy SocketClient Component
=============================

[](#legacy-socketclient-component)

[![Build Status](https://camo.githubusercontent.com/0d33b5f25e658ce81a405b53a7f5ddcc575d4d5ebdece239f09bf4fbd5045908/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f72656163747068702f736f636b65742d636c69656e742e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/reactphp/socket-client) [![Code Climate](https://camo.githubusercontent.com/62f09c8c5e7d1d27bb58c5c51f592debe2eedbeb973d3cf1643f9d3c04826a29/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f72656163747068702f736f636b65742d636c69656e742f6261646765732f6770612e737667)](https://codeclimate.com/github/reactphp/socket-client)

Async, streaming plaintext TCP/IP and secure TLS based connections for [ReactPHP](https://reactphp.org/)

You can think of this library as an async version of [`fsockopen()`](http://www.php.net/function.fsockopen) or [`stream_socket_client()`](http://php.net/function.stream-socket-client). If you want to transmit and receive data to/from a remote server, you first have to establish a connection to the remote end. Establishing this connection through the internet/network may take some time as it requires several steps (such as resolving target hostname, completing TCP/IP handshake and enabling TLS) in order to complete. This component provides an async version of all this so you can establish and handle multiple connections without blocking.

**Table of Contents**

- [Usage](#usage)
    - [ConnectorInterface](#connectorinterface)
        - [connect()](#connect)
    - [ConnectionInterface](#connectioninterface)
        - [getRemoteAddress()](#getremoteaddress)
        - [getLocalAddress()](#getlocaladdress)
    - [Connector](#connector)
- [Advanced Usage](#advanced-usage)
    - [TcpConnector](#tcpconnector)
    - [DnsConnector](#dnsconnector)
    - [SecureConnector](#secureconnector)
    - [TimeoutConnector](#timeoutconnector)
    - [UnixConnector](#unixconnector)
- [Install](#install)
- [Tests](#tests)
- [License](#license)

Usage
-----

[](#usage)

### ConnectorInterface

[](#connectorinterface)

The `ConnectorInterface` is responsible for providing an interface for establishing streaming connections, such as a normal TCP/IP connection.

This is the main interface defined in this package and it is used throughout React's vast ecosystem.

Most higher-level components (such as HTTP, database or other networking service clients) accept an instance implementing this interface to create their TCP/IP connection to the underlying networking service. This is usually done via dependency injection, so it's fairly simple to actually swap this implementation against any other implementation of this interface.

The interface only offers a single method:

#### connect()

[](#connect)

The `connect(string $uri): PromiseInterface` method can be used to create a streaming connection to the given remote address.

It returns a [Promise](https://github.com/reactphp/promise) which either fulfills with a stream implementing [`ConnectionInterface`](#connectioninterface)on success or rejects with an `Exception` if the connection is not successful:

```
$connector->connect('google.com:443')->then(
    function (ConnectionInterface $connection) {
        // connection successfully established
    },
    function (Exception $error) {
        // failed to connect due to $error
    }
);
```

See also [`ConnectionInterface`](#connectioninterface) for more details.

The returned Promise MUST be implemented in such a way that it can be cancelled when it is still pending. Cancelling a pending promise MUST reject its value with an `Exception`. It SHOULD clean up any underlying resources and references as applicable:

```
$promise = $connector->connect($uri);

$promise->cancel();
```

### ConnectionInterface

[](#connectioninterface)

The `ConnectionInterface` is used to represent any outgoing connection, such as a normal TCP/IP connection.

An outgoing connection is a duplex stream (both readable and writable) that implements React's [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface). It contains additional properties for the local and remote address where this connection has been established to.

Most commonly, instances implementing this `ConnectionInterface` are returned by all classes implementing the [`ConnectorInterface`](#connectorinterface).

> Note that this interface is only to be used to represent the client-side end of an outgoing connection. It MUST NOT be used to represent an incoming connection in a server-side context. If you want to accept incoming connections, use the [`Socket`](https://github.com/reactphp/socket) component instead.

Because the `ConnectionInterface` implements the underlying [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface)you can use any of its events and methods as usual:

```
$connection->on('data', function ($chunk) {
    echo $chunk;
});

$connection->on('end', function () {
    echo 'ended';
});

$connection->on('error', function (Exception $e) {
    echo 'error: ' . $e->getMessage();
});

$connection->on('close', function () {
    echo 'closed';
});

$connection->write($data);
$connection->end($data = null);
$connection->close();
// …
```

For more details, see the [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface).

#### getRemoteAddress()

[](#getremoteaddress)

The `getRemoteAddress(): ?string` method can be used to return the remote address (IP and port) where this connection has been established to.

```
$address = $connection->getRemoteAddress();
echo 'Connected to ' . $address . PHP_EOL;
```

If the remote address can not be determined or is unknown at this time (such as after the connection has been closed), it MAY return a `NULL` value instead.

Otherwise, it will return the full remote address as a string value. If this is a TCP/IP based connection and you only want the remote IP, you may use something like this:

```
$address = $connection->getRemoteAddress();
$ip = trim(parse_url('tcp://' . $address, PHP_URL_HOST), '[]');
echo 'Connected to ' . $ip . PHP_EOL;
```

#### getLocalAddress()

[](#getlocaladdress)

The `getLocalAddress(): ?string` method can be used to return the full local address (IP and port) where this connection has been established from.

```
$address = $connection->getLocalAddress();
echo 'Connected via ' . $address . PHP_EOL;
```

If the local address can not be determined or is unknown at this time (such as after the connection has been closed), it MAY return a `NULL` value instead.

Otherwise, it will return the full local address as a string value.

This method complements the [`getRemoteAddress()`](#getremoteaddress) method, so they should not be confused.

If your system has multiple interfaces (e.g. a WAN and a LAN interface), you can use this method to find out which interface was actually used for this connection.

### Connector

[](#connector)

The `Connector` class is the main class in this package that implements the [`ConnectorInterface`](#connectorinterface) and allows you to create streaming connections.

You can use this connector to create any kind of streaming connections, such as plaintext TCP/IP, secure TLS or local Unix connection streams.

It binds to the main event loop and can be used like this:

```
$loop = React\EventLoop\Factory::create();
$connector = new Connector($loop);

$connector->connect($uri)->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});

$loop->run();
```

In order to create a plaintext TCP/IP connection, you can simply pass a host and port combination like this:

```
$connector->connect('www.google.com:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

> If you do no specify a URI scheme in the destination URI, it will assume `tcp://` as a default and establish a plaintext TCP/IP connection. Note that TCP/IP connections require a host and port part in the destination URI like above, all other URI components are optional.

In order to create a secure TLS connection, you can use the `tls://` URI scheme like this:

```
$connector->connect('tls://www.google.com:443')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

In order to create a local Unix domain socket connection, you can use the `unix://` URI scheme like this:

```
$connector->connect('unix:///tmp/demo.sock')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

Under the hood, the `Connector` is implemented as a *higher-level facade*for the lower-level connectors implemented in this package. This means it also shares all of their features and implementation details. If you want to typehint in your higher-level protocol implementation, you SHOULD use the generic [`ConnectorInterface`](#connectorinterface) instead.

In particular, the `Connector` class uses Google's public DNS server `8.8.8.8`to resolve all hostnames into underlying IP addresses by default. This implies that it also ignores your `hosts` file and `resolve.conf`, which means you won't be able to connect to `localhost` and other non-public hostnames by default. If you want to use a custom DNS server (such as a local DNS relay), you can set up the `Connector` like this:

```
$connector = new Connector($loop, array(
    'dns' => '127.0.1.1'
));

$connector->connect('localhost:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

If you do not want to use a DNS resolver at all and want to connect to IP addresses only, you can also set up your `Connector` like this:

```
$connector = new Connector($loop, array(
    'dns' => false
));

$connector->connect('127.0.0.1:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

Advanced: If you need a custom DNS `Resolver` instance, you can also set up your `Connector` like this:

```
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$resolver = $dnsResolverFactory->createCached('127.0.1.1', $loop);

$connector = new Connector($loop, array(
    'dns' => $resolver
));

$connector->connect('localhost:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

By default, the `tcp://` and `tls://` URI schemes will use timeout value that repects your `default_socket_timeout` ini setting (which defaults to 60s). If you want a custom timeout value, you can simply pass this like this:

```
$connector = new Connector($loop, array(
    'timeout' => 10.0
));
```

Similarly, if you do not want to apply a timeout at all and let the operating system handle this, you can pass a boolean flag like this:

```
$connector = new Connector($loop, array(
    'timeout' => false
));
```

By default, the `Connector` supports the `tcp://`, `tls://` and `unix://`URI schemes. If you want to explicitly prohibit any of these, you can simply pass boolean flags like this:

```
// only allow secure TLS connections
$connector = new Connector($loop, array(
    'tcp' => false,
    'tls' => true,
    'unix' => false,
));

$connector->connect('tls://google.com:443')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

The `tcp://` and `tls://` also accept additional context options passed to the underlying connectors. If you want to explicitly pass additional context options, you can simply pass arrays of context options like this:

```
// allow insecure TLS connections
$connector = new Connector($loop, array(
    'tcp' => array(
        'bindto' => '192.168.0.1:0'
    ),
    'tls' => array(
        'verify_peer' => false,
        'verify_peer_name' => false
    ),
));

$connector->connect('tls://localhost:443')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

> For more details about context options, please refer to the PHP documentation about [socket context options](http://php.net/manual/en/context.socket.php)and [SSL context options](http://php.net/manual/en/context.ssl.php).

Advanced: By default, the `Connector` supports the `tcp://`, `tls://` and `unix://` URI schemes. For this, it sets up the required connector classes automatically. If you want to explicitly pass custom connectors for any of these, you can simply pass an instance implementing the `ConnectorInterface` like this:

```
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$resolver = $dnsResolverFactory->createCached('127.0.1.1', $loop);
$tcp = new DnsConnector(new TcpConnector($loop), $resolver);

$tls = new SecureConnector($tcp, $loop);

$unix = new UnixConnector($loop);

$connector = new Connector($loop, array(
    'tcp' => $tcp,
    'tls' => $tls,
    'unix' => $unix,

    'dns' => false,
    'timeout' => false,
));

$connector->connect('google.com:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});
```

> Internally, the `tcp://` connector will always be wrapped by the DNS resolver, unless you disable DNS like in the above example. In this case, the `tcp://`connector receives the actual hostname instead of only the resolved IP address and is thus responsible for performing the lookup. Internally, the automatically created `tls://` connector will always wrap the underlying `tcp://` connector for establishing the underlying plaintext TCP/IP connection before enabling secure TLS mode. If you want to use a custom underlying `tcp://` connector for secure TLS connections only, you may explicitly pass a `tls://` connector like above instead. Internally, the `tcp://` and `tls://` connectors will always be wrapped by `TimeoutConnector`, unless you disable timeouts like in the above example.

Advanced Usage
--------------

[](#advanced-usage)

### TcpConnector

[](#tcpconnector)

The `React\SocketClient\TcpConnector` class implements the [`ConnectorInterface`](#connectorinterface) and allows you to create plaintext TCP/IP connections to any IP-port-combination:

```
$tcpConnector = new React\SocketClient\TcpConnector($loop);

$tcpConnector->connect('127.0.0.1:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});

$loop->run();
```

See also the [first example](examples).

Pending connection attempts can be cancelled by cancelling its pending promise like so:

```
$promise = $tcpConnector->connect('127.0.0.1:80');

$promise->cancel();
```

Calling `cancel()` on a pending promise will close the underlying socket resource, thus cancelling the pending TCP/IP connection, and reject the resulting promise.

You can optionally pass additional [socket context options](http://php.net/manual/en/context.socket.php)to the constructor like this:

```
$tcpConnector = new React\SocketClient\TcpConnector($loop, array(
    'bindto' => '192.168.0.1:0'
));
```

Note that this class only allows you to connect to IP-port-combinations. If the given URI is invalid, does not contain a valid IP address and port or contains any other scheme, it will reject with an `InvalidArgumentException`:

If the given URI appears to be valid, but connecting to it fails (such as if the remote host rejects the connection etc.), it will reject with a `RuntimeException`.

If you want to connect to hostname-port-combinations, see also the following chapter.

> Advanced usage: Internally, the `TcpConnector` allocates an empty *context*resource for each stream resource. If the destination URI contains a `hostname` query parameter, its value will be used to set up the TLS peer name. This is used by the `SecureConnector` and `DnsConnector` to verify the peer name and can also be used if you want a custom TLS peer name.

### DnsConnector

[](#dnsconnector)

The `DnsConnector` class implements the [`ConnectorInterface`](#connectorinterface) and allows you to create plaintext TCP/IP connections to any hostname-port-combination.

It does so by decorating a given `TcpConnector` instance so that it first looks up the given domain name via DNS (if applicable) and then establishes the underlying TCP/IP connection to the resolved target IP address.

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

```
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);

$dnsConnector = new React\SocketClient\DnsConnector($tcpConnector, $dns);

$dnsConnector->connect('www.google.com:80')->then(function (ConnectionInterface $connection) {
    $connection->write('...');
    $connection->end();
});

$loop->run();
```

See also the [first example](examples).

Pending connection attempts can be cancelled by cancelling its pending promise like so:

```
$promise = $dnsConnector->connect('www.google.com:80');

$promise->cancel();
```

Calling `cancel()` on a pending promise will cancel the underlying DNS lookup and/or the underlying TCP/IP connection and reject the resulting promise.

> Advanced usage: Internally, the `DnsConnector` relies on a `Resolver` to look up the IP address for the given hostname. It will then replace the hostname in the destination URI with this IP and append a `hostname` query parameter and pass this updated URI to the underlying connector. The underlying connector is thus responsible for creating a connection to the target IP address, while this query parameter can be used to check the original hostname and is used by the `TcpConnector` to set up the TLS peer name. If a `hostname` is given explicitly, this query parameter will not be modified, which can be useful if you want a custom TLS peer name.

### SecureConnector

[](#secureconnector)

The `SecureConnector` class implements the [`ConnectorInterface`](#connectorinterface) and allows you to create secure TLS (formerly known as SSL) connections to any hostname-port-combination.

It does so by decorating a given `DnsConnector` instance so that it first creates a plaintext TCP/IP connection and then enables TLS encryption on this stream.

```
$secureConnector = new React\SocketClient\SecureConnector($dnsConnector, $loop);

$secureConnector->connect('www.google.com:443')->then(function (ConnectionInterface $connection) {
    $connection->write("GET / HTTP/1.0\r\nHost: www.google.com\r\n\r\n");
    ...
});

$loop->run();
```

See also the [second example](examples).

Pending connection attempts can be cancelled by cancelling its pending promise like so:

```
$promise = $secureConnector->connect('www.google.com:443');

$promise->cancel();
```

Calling `cancel()` on a pending promise will cancel the underlying TCP/IP connection and/or the SSL/TLS negonation and reject the resulting promise.

You can optionally pass additional [SSL context options](http://php.net/manual/en/context.ssl.php)to the constructor like this:

```
$secureConnector = new React\SocketClient\SecureConnector($dnsConnector, $loop, array(
    'verify_peer' => false,
    'verify_peer_name' => false
));
```

> Advanced usage: Internally, the `SecureConnector` relies on setting up the required *context options* on the underlying stream resource. It should therefor be used with a `TcpConnector` somewhere in the connector stack so that it can allocate an empty *context* resource for each stream resource and verify the peer name. Failing to do so may result in a TLS peer name mismatch error or some hard to trace race conditions, because all stream resources will use a single, shared *default context* resource otherwise.

### TimeoutConnector

[](#timeoutconnector)

The `TimeoutConnector` class implements the [`ConnectorInterface`](#connectorinterface) and allows you to add timeout handling to any existing connector instance.

It does so by decorating any given [`ConnectorInterface`](#connectorinterface)instance and starting a timer that will automatically reject and abort any underlying connection attempt if it takes too long.

```
$timeoutConnector = new React\SocketClient\TimeoutConnector($connector, 3.0, $loop);

$timeoutConnector->connect('google.com:80')->then(function (ConnectionInterface $connection) {
    // connection succeeded within 3.0 seconds
});
```

See also any of the [examples](examples).

Pending connection attempts can be cancelled by cancelling its pending promise like so:

```
$promise = $timeoutConnector->connect('google.com:80');

$promise->cancel();
```

Calling `cancel()` on a pending promise will cancel the underlying connection attempt, abort the timer and reject the resulting promise.

### UnixConnector

[](#unixconnector)

The `UnixConnector` class implements the [`ConnectorInterface`](#connectorinterface) and allows you to connect to Unix domain socket (UDS) paths like this:

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

$connector->connect('/tmp/demo.sock')->then(function (ConnectionInterface $connection) {
    $connection->write("HELLO\n");
});

$loop->run();
```

Connecting to Unix domain sockets is an atomic operation, i.e. its promise will settle (either resolve or reject) immediately. As such, calling `cancel()` on the resulting promise has no effect.

Install
-------

[](#install)

The recommended way to install this library is [through Composer](http://getcomposer.org). [New to Composer?](http://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```
$ composer require react/socket-client:^0.7
```

More details about version upgrades can be found in the [CHANGELOG](CHANGELOG.md).

This project supports running on legacy PHP 5.3 through current PHP 7+ and HHVM. It's *highly recommended to use PHP 7+* for this project, partly due to its vast performance improvements and partly because legacy PHP versions require several workarounds as described below.

Secure TLS connections received some major upgrades starting with PHP 5.6, with the defaults now being more secure, while older versions required explicit context options. This library does not take responsibility over these context options, so it's up to consumers of this library to take care of setting appropriate context options as described above.

All versions of PHP prior to 5.6.8 suffered from a buffering issue where reading from a streaming TLS connection could be one `data` event behind. This library implements a work-around to try to flush the complete incoming data buffers on these versions, but we have seen reports of people saying this could still affect some older versions (`5.5.23`, `5.6.7`, and `5.6.8`). Note that this only affects *some* higher-level streaming protocols, such as IRC over TLS, but should not affect HTTP over TLS (HTTPS). Further investigation of this issue is needed. For more insights, this issue is also covered by our test suite.

This project also supports running on HHVM. Note that really old HHVM &lt; 3.8 does not support secure TLS connections, as it lacks the required `stream_socket_enable_crypto()` function. As such, trying to create a secure TLS connections on affected versions will return a rejected promise instead. This issue is also covered by our test suite, which will skip related tests on affected versions.

Tests
-----

[](#tests)

To run the test suite, you first need to clone this repo and then install all dependencies [through Composer](http://getcomposer.org):

```
$ composer install
```

To run the test suite, go to the project root and run:

```
$ php vendor/bin/phpunit
```

License
-------

[](#license)

MIT, see [LICENSE file](LICENSE).

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity57

Moderate usage in the ecosystem

Community39

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~11 days

Total

21

Last Release

3379d ago

PHP version history (3 changes)v0.3.0PHP &gt;=5.3.3

v0.4.0PHP &gt;=5.4.0

v0.5.0PHP &gt;=5.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

![](https://avatars.githubusercontent.com/u/776829?v=4)[Christian Lück](/maintainers/clue)[@clue](https://github.com/clue)

![](https://www.gravatar.com/avatar/5de14776bbddf901c6e24d35829fe66fe997c303d53aca83cc7d1a90bb0b7110?d=identicon)[jsor](/maintainers/jsor)

![](https://avatars.githubusercontent.com/u/88061?v=4)[Igor](/maintainers/igorw)[@igorw](https://github.com/igorw)

![](https://www.gravatar.com/avatar/abeb36727bb30a42ef26abe8e6c1152917648fa2ae7259e0038ac9644218e27a?d=identicon)[cboden](/maintainers/cboden)

---

Top Contributors

[![clue](https://avatars.githubusercontent.com/u/776829?v=4)](https://github.com/clue "clue (109 commits)")[![cboden](https://avatars.githubusercontent.com/u/617694?v=4)](https://github.com/cboden "cboden (40 commits)")[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (29 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (7 commits)")[![jsor](https://avatars.githubusercontent.com/u/55574?v=4)](https://github.com/jsor "jsor (1 commits)")[![e3betht](https://avatars.githubusercontent.com/u/1811561?v=4)](https://github.com/e3betht "e3betht (1 commits)")[![DaveRandom](https://avatars.githubusercontent.com/u/2396425?v=4)](https://github.com/DaveRandom "DaveRandom (1 commits)")[![alexmace](https://avatars.githubusercontent.com/u/207391?v=4)](https://github.com/alexmace "alexmace (1 commits)")[![elliot](https://avatars.githubusercontent.com/u/9938?v=4)](https://github.com/elliot "elliot (1 commits)")

---

Tags

streamasyncreactphpSocketConnection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/react-socket-client/health.svg)

```
[![Health](https://phpackages.com/badges/react-socket-client/health.svg)](https://phpackages.com/packages/react-socket-client)
```

###  Alternatives

[react/socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP

1.3k135.6M458](/packages/react-socket)[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[react/promise-stream

The missing link between Promise-land and Stream-land for ReactPHP

11613.2M48](/packages/react-promise-stream)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113163.3k1](/packages/clue-docker-react)[react/datagram

Event-driven UDP datagram socket client and server for ReactPHP

99868.6k45](/packages/react-datagram)[clue/reactphp-eventsource

Instant real-time updates. Lightweight EventSource client receiving live messages via HTML5 Server-Sent Events (SSE). Fast stream processing built on top of ReactPHP's event-driven architecture.

5819.9k3](/packages/clue-reactphp-eventsource)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
