PHPackages                             juanchosl/socketclient - 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. juanchosl/socketclient

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

juanchosl/socketclient
======================

Little methods collection in order to connect and use some socket connections from distinct types of origins

1.0.0(5mo ago)1511MITPHPPHP ^8.0

Since Jan 19Pushed 5mo agoCompare

[ Source](https://github.com/JuanchoSL/SocketClient)[ Packagist](https://packagist.org/packages/juanchosl/socketclient)[ Docs](https://github.com/JuanchoSL/SocketClient)[ RSS](/packages/juanchosl-socketclient/feed)WikiDiscussions 1.0 Synced today

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

SocketClient
============

[](#socketclient)

Little methods collection in order to connect and use some socket connections from distinct types of origins

Raw
---

[](#raw)

### Sockets

[](#sockets)

It's the most simple sockets use, using the sockets php library, can be used for tcp and udp connections. No need factory, using full domain on construct, with protocol as schema, it parse and config the socket\_client

```
$client = new RawSocketClient('tcp://host.docker.internal:8001');
```

Stream
------

[](#stream)

Powerfull socket type, using streams, can be instantiated or use the Factory in order to auto-select the rigth Client type

```
$stream = (new StreamSocketClientFactory)->createFromUrl('ftp://ftp.ftpserver.com:21');
```

Compatible (and really tested) Protocols

SelectedUsedClasstcptcpStreamSocketClientudpudpStreamSocketClientftptcpStreamSocketClientftpstlsSecureStreamSocketClientsslsslSecureStreamSocketClienttlstlsSecureStreamSocketClientwstcpWebSocketClientwsssslSecureWebSocketClientAvailable methods

MethodDescriptionconstructSet the url and prepare the instance for future connectionconnecttry to establish a real connection with the prepared serverisConnectedreturn true or false in order to know the connection statusdisconnectclose the connectionsetBlockingModeset true or false for enable or disable the blocking mode with the connected serverreadtry to read n bytes from buffer, if block mode is enabled, wait for receive some datawritesend a command or data to the socket servergetMetadatareturns an array with the headers or server metadatagetErrorwhen an error exists, retrieve the code and the message and throw an ExceptionsetCryptoOnly for secure sockets (Streams and Web)### Stream Socket

[](#stream-socket)

For use with own servers, Email, FTP, etc...

```
$socket = (new StreamSocketClientFactory)->createFromUrl('ftps://ftp.ftpserver.com:21');
$socket->connect();
echo $socket->read(); //220-Juancho's home SSH server
$socket->write("AUTH TLS\r\n");
echo $response = $socket->read(); //234 Security mechanism set to TLS
if (str_starts_with($response, 234)) {
    $socket->setCrypto(true);
    $socket->write("USER username\r\n");
    echo $response = $socket->read(); //331 Need password
    $socket->write("PASS password\r\n");
    echo $response = $socket->read(); //230 User logged in (elevated)
}
$socket->write("QUIT\r\n");
echo $response = $socket->read(); //221 Service closing control connection
```

### Web Sockets

[](#web-sockets)

This is an extension of StreamSocket (normal and secure) but perform the needed handshake with the server on connect. Actually, it do a handshake v1, but we are in process to implements v2 and v3

[![WSS local connection.](/assets/websocket.png "This is a real example of a wss connection.")](/assets/websocket.png)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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

Total

2

Last Release

166d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18701207?v=4)[Juan Sánchez](/maintainers/Juanchosl)[@JuanchoSL](https://github.com/JuanchoSL)

---

Top Contributors

[![JuanchoSL](https://avatars.githubusercontent.com/u/18701207?v=4)](https://github.com/JuanchoSL "JuanchoSL (16 commits)")

---

Tags

socketstcpStreamsudpweb-sockets

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juanchosl-socketclient/health.svg)

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

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k869.4M8.8k](/packages/symfony-http-kernel)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k338.8M5.0k](/packages/symfony-http-client)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

3.9k691.5k13](/packages/hhxsv5-laravel-s)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M219](/packages/api-platform-metadata)[bitrix24/b24phpsdk

An official PHP library for the Bitrix24 REST API

10244.2k5](/packages/bitrix24-b24phpsdk)

PHPackages © 2026

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