PHPackages                             ulises58/simple-tcp-server - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ulises58/simple-tcp-server

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ulises58/simple-tcp-server
==========================

A simple tcp server written in PHP

213PHP

Since Jul 8Pushed 5y agoCompare

[ Source](https://github.com/ulises58/SimpleTcpServer)[ Packagist](https://packagist.org/packages/ulises58/simple-tcp-server)[ RSS](/packages/ulises58-simple-tcp-server/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Simple TCP Server
=================

[](#simple-tcp-server)

There are two tcp server. The one is blocking tcp server, then the other is non-blocking tcp server.

`BlockServer` is limited and accept only one client. It means that the server can handle only one connection at a time. Only when the client leaved and close the connection can next client be processed by server.

`SelectServer` built upon `system Select()` is better than `BlockServer` due to non-blocking feature. So the server can accept multiple client simultaneously.

Examples
--------

[](#examples)

### Echo Server

[](#echo-server)

`php examples/EchoServer.php`

```
// require autoload file from composer
require __DIR__ . '/../vendor/autoload.php';

class Logger extends \Psr\Log\AbstractLogger
{
    public function log($level, $message, array $context = array())
    {
        echo sprintf("%s: %s %s", $level, $message, !empty($context) ? json_encode($context) : '') . PHP_EOL;
    }
}

// listen on address 127.0.0.1 and port 8000
$echoServer = new \Hbliang\SimpleTcpServer\SelectServer('127.0.0.1', 8000);
//$echoServer = new \Hbliang\SimpleTcpServer\BlockServer('127.0.0.1', 8000);

// trigger while receiving data from client
$echoServer->on('data', function (\Hbliang\SimpleTcpServer\Connection $connection, $data) {
    // send data to client
    $connection->write($data . PHP_EOL);
});

// trigger when new connection comes
$echoServer->on('connection', function (\Hbliang\SimpleTcpServer\Connection $connection) {
    $connection->write('welcome' .PHP_EOL);
});

// trigger when occur error
$echoServer->on('error', function (\Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

$echoServer->setLogger(new Logger());

$echoServer->run();
```

Reference
---------

[](#reference)

- [ReactPHP](https://github.com/reactphp/react)
- [Workerman](https://github.com/walkor/Workerman)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.9% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10949545?v=4)[Ulises Sandoval](/maintainers/ulises58)[@ulises58](https://github.com/ulises58)

---

Top Contributors

[![ulises58](https://avatars.githubusercontent.com/u/10949545?v=4)](https://github.com/ulises58 "ulises58 (10 commits)")[![hbliang](https://avatars.githubusercontent.com/u/12814637?v=4)](https://github.com/hbliang "hbliang (1 commits)")

### Embed Badge

![Health badge](/badges/ulises58-simple-tcp-server/health.svg)

```
[![Health](https://phpackages.com/badges/ulises58-simple-tcp-server/health.svg)](https://phpackages.com/packages/ulises58-simple-tcp-server)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M318](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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