PHPackages                             matasarei/phptcp - 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. matasarei/phptcp

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

matasarei/phptcp
================

A TCP client for PHP

1.1(2y ago)1121MITPHPPHP &gt;=7.1

Since Sep 1Pushed 2y ago2 watchersCompare

[ Source](https://github.com/matasarei/phptcp)[ Packagist](https://packagist.org/packages/matasarei/phptcp)[ RSS](/packages/matasarei-phptcp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

PHP TCP
=======

[](#php-tcp)

[![example workflow](https://github.com/matasarei/phptcp/actions/workflows/tests.yml/badge.svg)](https://github.com/matasarei/phptcp/actions/workflows/tests.yml/badge.svg)

A TCP client for PHP. This is a demo library: it is provided as is, without any guarantees.

Basic usage
-----------

[](#basic-usage)

```
use Matasar\PhpTcp\Client;
use Matasar\PhpTcp\Request;
use Matasar\PhpTcp\Socket\StreamSocket;

$client = new Client('ip_or_hostname', 8888, new StreamSocket());
$client->connect();

$request = new Request('request');
$response = $client->request($request);
$client->disconnect();

var_dump($response->getData());
```

Socket interface
----------------

[](#socket-interface)

The lib includes two socket interfaces to use: `StreamSocket` and `FSocket`. The difference is between using `stream_socket_client` and `fsockopen`. Choose one you need or like more or implement your own class.

Also, there is the blocking setting you can change:

```
use Matasar\PhpTcp\Socket\FSocket;

new FSocket(0); // disable blocking.
```

Client settings
---------------

[](#client-settings)

```
use Matasar\PhpTcp\Client;
use Matasar\PhpTcp\Socket\FSocket;

$client = new Client('hostname', 1234, new FSocket());

$client->setChunkSize(8192); // read data by 8 Kb per cycle.
$client->setConnectionLag(5000); // 5 ms pause per cycle.
$client->setLogger(new SomePsrLogger()); // connect a logger for debugging.
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

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

###  Release Activity

Cadence

Every ~822 days

Total

2

Last Release

897d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44632227efd38dd8598ceb71812e223865e994f1f35f027b423469133fb29d6b?d=identicon)[matasarei](/maintainers/matasarei)

---

Top Contributors

[![matasarei](https://avatars.githubusercontent.com/u/6638367?v=4)](https://github.com/matasarei "matasarei (6 commits)")

---

Tags

clientsockettcp-client

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matasarei-phptcp/health.svg)

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

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k822.4M6.8k](/packages/symfony-http-kernel)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)

PHPackages © 2026

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