Thruster Socket Component

1.1.0 2016-01-14 16:10 UTC

This package is auto-updated.

Last update: 2024-04-14 01:57:14 UTC


[Latest Version] ( [Software License] (LICENSE) [Build Status] ( [Code Coverage] ( [Quality Score] ( [Total Downloads] (

[Email] (

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 and Stream components.


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


The Connection is a readable and writable 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 component instead.


Via Composer

$ composer require thruster/socket


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) {


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

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


$ composer test


Please see CONTRIBUTING and CONDUCT for details.


Please see License File for more information.