PHPackages                             thruster/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. thruster/socket

ActiveLibrary

thruster/socket
===============

Thruster Socket Component

1.1.0(10y ago)04041MITPHPPHP &gt;=7.0

Since Dec 12Pushed 10y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (4)Versions (4)Used By (1)

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

[](#socket-component)

\[[![Latest Version](https://camo.githubusercontent.com/8889c58d63a832260631c8b16c2fdb32a13539bb87d129671b59b623e1452b67/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8889c58d63a832260631c8b16c2fdb32a13539bb87d129671b59b623e1452b67/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)\] () \[[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)\] (LICENSE) \[[![Build Status](https://camo.githubusercontent.com/0dd868490b7dc80dfed62c35820f098497cdf9dee85aef9cfd08838fc1d35515/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/0dd868490b7dc80dfed62c35820f098497cdf9dee85aef9cfd08838fc1d35515/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)\] () \[[![Code Coverage](https://camo.githubusercontent.com/4eb3816093ace119c92b9d17a30ebdeefb71e4ebe1dacb63d9a60ef59e55cb84/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4eb3816093ace119c92b9d17a30ebdeefb71e4ebe1dacb63d9a60ef59e55cb84/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)\] () \[[![Quality Score](https://camo.githubusercontent.com/cd8f7fe201cb7d57bef573017c1ce8cde1dfbc11995993a694c55cd6482b379c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/cd8f7fe201cb7d57bef573017c1ce8cde1dfbc11995993a694c55cd6482b379c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f5468727573746572494f2f736f636b65742e7376673f7374796c653d666c61742d737175617265)\] () \[[![Total Downloads](https://camo.githubusercontent.com/3c422b7b8fdf4a2e36105f754ce70c45db66171450b3749c2ce192eff8cd7002/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74687275737465722f736f636b65742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/3c422b7b8fdf4a2e36105f754ce70c45db66171450b3749c2ce192eff8cd7002/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74687275737465722f736f636b65742e7376673f7374796c653d666c61742d737175617265)\] ()

\[[![Email](https://camo.githubusercontent.com/fc4998410b6b71d697bf556c37294970fedc130c081c82698cdb5ca22d70cade/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f656d61696c2d7465616d4074687275737465722e696f2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/fc4998410b6b71d697bf556c37294970fedc130c081c82698cdb5ca22d70cade/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f656d61696c2d7465616d4074687275737465722e696f2d626c75652e7376673f7374796c653d666c61742d737175617265)\] ()

The Thruster Socket Component.

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`](https://github.com/ThrusterIO/event-loop)and [`Stream`](https://github.com/ThrusterIO/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`](https://github.com/ThrusterIO/stream). The incoming connection represents the server-side end of the connection.

It MUST NOT be used to represent an outgoing connection in a client-side context. If you want to establish an outgoing connection, use the [`SocketClient`](https://github.com/ThrusterIO/socket-client) component instead.

Install
-------

[](#install)

Via Composer

```
$ composer require thruster/socket
```

Usage
-----

[](#usage)

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

```
$loop = new EventLoop();

$socket = new Server($loop);
$socket->on('connection', function ($conn) {
    $conn->write("Hello world!\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');
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

License
-------

[](#license)

Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

3767d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/770bae1f46ac2b4536db820b8642491c25e2e2fd44e761110269e4722679a80d?d=identicon)[aurimasniekis](/maintainers/aurimasniekis)

---

Tags

Socketthruster

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/thruster-socket/health.svg)](https://phpackages.com/packages/thruster-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)[hollodotme/fast-cgi-client

A PHP fast CGI client to send requests (a)synchronously to PHP-FPM.

56423.9M25](/packages/hollodotme-fast-cgi-client)[clue/socket-raw

Simple and lightweight OOP wrapper for PHP's low-level sockets extension (ext-sockets).

35111.1M48](/packages/clue-socket-raw)[davidpersson/beanstalk

Minimalistic PHP client for beanstalkd.

200321.9k8](/packages/davidpersson-beanstalk)[react/datagram

Event-driven UDP datagram socket client and server for ReactPHP

99759.5k36](/packages/react-datagram)[stefanak-michal/bolt

PHP library to provide connectivity to graph database over TCP socket with Bolt specification

79655.8k8](/packages/stefanak-michal-bolt)

PHPackages © 2026

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