PHPackages                             webbeta/socket - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. webbeta/socket

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webbeta/socket
==============

Library for building an evented socket server.

v0.4.2(11y ago)019MITPHPPHP &gt;=5.4.0

Since Jul 11Pushed 11y ago1 watchersCompare

[ Source](https://github.com/webetes/socket)[ Packagist](https://packagist.org/packages/webbeta/socket)[ RSS](/packages/webbeta-socket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (16)Used By (0)

Socket Component
================

[](#socket-component)

[![Build Status](https://camo.githubusercontent.com/e3a1f00c0fe34afaa42d311f73c6dbcf8084307b24b36bf7866f052f2cbe8a06/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f72656163747068702f736f636b65742e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/reactphp/socket)

Library for building an evented socket server.

The socket component provides a more usable interface for a socket-layer server or client based on the `EventLoop` and `Stream` components.

Server
------

[](#server)

The server can listen on a port and will emit a `connection` event whenever a client connects.

Connection
----------

[](#connection)

The connection is a readable and writable stream. It can be used in a server or in a client context.

Usage
-----

[](#usage)

Here is a server that closes the connection if you send it anything.

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

    $socket = new React\Socket\Server($loop);
    $socket->on('connection', function ($conn) {
        $conn->write("Hello there!\n");
        $conn->write("Welcome to this amazing server!\n");
        $conn->write("Here's a tip: don't say anything.\n");

        $conn->on('data', function ($data) use ($conn) {
            $conn->close();
        });
    });
    $socket->listen(1337);

    $loop->run();
```

You can change the host the socket is listening on through a second parameter provided to the listen method:

```
    $socket->listen(1337, '192.168.0.1');
```

Here's a client that outputs the output of said server and then attempts to send it a string.

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

    $client = stream_socket_client('tcp://127.0.0.1:1337');
    $conn = new React\Socket\Connection($client, $loop);
    $conn->pipe(new React\Stream\Stream(STDOUT, $loop));
    $conn->write("Hello World!\n");

    $loop->run();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~52 days

Recently: every ~28 days

Total

14

Last Release

4374d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.2

v0.2.0PHP &gt;=5.3.3

v0.4.0PHP &gt;=5.4.0

### Community

Maintainers

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

---

Top Contributors

[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (40 commits)")[![cboden](https://avatars.githubusercontent.com/u/617694?v=4)](https://github.com/cboden "cboden (38 commits)")[![clue](https://avatars.githubusercontent.com/u/776829?v=4)](https://github.com/clue "clue (6 commits)")[![mowcixo](https://avatars.githubusercontent.com/u/47653?v=4)](https://github.com/mowcixo "mowcixo (2 commits)")[![Sgoettschkes](https://avatars.githubusercontent.com/u/628796?v=4)](https://github.com/Sgoettschkes "Sgoettschkes (1 commits)")

---

Tags

Socket

### Embed Badge

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

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

###  Alternatives

[react/socket

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

1.3k116.9M402](/packages/react-socket)[react/child-process

Event-driven library for executing child processes with ReactPHP.

34076.1M136](/packages/react-child-process)[trafficcophp/bytebuffer

Node.js inspired byte stream buffer for PHP.

33437.2k17](/packages/trafficcophp-bytebuffer)[zoon/rialto

Manage Node resources from PHP

12199.4k3](/packages/zoon-rialto)

PHPackages © 2026

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