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 3w ago

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 9% 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

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M89](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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