PHPackages                             antibiotics11/net-socket - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. antibiotics11/net-socket

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antibiotics11/net-socket
========================

Utility classes for PHP socket programming.

04PHP

Since May 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/antibiotics11/net-socket)[ Packagist](https://packagist.org/packages/antibiotics11/net-socket)[ RSS](/packages/antibiotics11-net-socket/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

net-socket
==========

[](#net-socket)

Utility classes for PHP socket programming.

Classes
-------

[](#classes)

- **NetSocket\\InetAddress:** represents an ip address, domain name, and address family.
- **NetSocket\\Endpoint:** represents a network endpoint with InetAddress and port number pairs.
- **NetSocket\\Socket\\Wrapper\\Socket:** wraps PHP Socket object and socket functions.
- **NetSocket\\Socket\\Wrapper\\SocketError:** wraps PHP socket errors.

Usage
-----

[](#usage)

### TCP server

[](#tcp-server)

```
use antibiotics11\NetSocket\{InetAddress, Endpoint};
use antibiotics11\NetSocket\Socket\Wrapper\{Socket, SocketError};

// Define the server endpoint
$serverEndpoint = new Endpoint(
  inetAddress: InetAddress::getByAddress("127.0.0.1"),
  port:        12345
);

try {

  // Create a server socket
  $serverSocket = Socket::create(
    domain: Socket::DOMAIN_INET,
    type:   Socket::TYPE_STREAM,
    level:  Socket::LEVEL_TCP
  );

  // Bind the server socket to the server endpoint
  $serverSocket->bindTo(endpoint: $serverEndpoint);

  // Start listening for incoming connections
  $serverSocket->listen();

  // Accept an incoming connection
  $clientSocket = $serverSocket->accept();

  // Read data from the client
  $receivedData = $clientSocket->read();

  // Get the remote endpoint of the client
  $clientEndpoint = $clientSocket->getRemoteEndpoint();

  printf("Received \"%s\" from %s\r\n", $receivedData, $clientEndpoint);

  // Shut down the client socket
  $clientSocket->shutdown();

  // Close the server socket
  $serverSocket->close();

} catch (SocketError $e) {
  printf("Socket Error: %s\r\n", $e->getSocketErrorMessage());
}
```

### TCP client

[](#tcp-client)

```
use antibiotics11\NetSocket\{InetAddress, Endpoint};
use antibiotics11\NetSocket\Socket\Wrapper\{Socket, SocketError};

// Define the server endpoint to connect to
$serverEndpoint = new Endpoint(
  inetAddress: InetAddress::getByAddress("127.0.0.1"),
  port:        12345
);

try {

  // Create a client socket
  $clientSocket = Socket::create(
    domain: Socket::DOMAIN_INET,
    type:   Socket::TYPE_STREAM,
    level:  Socket::LEVEL_TCP
  );

  // Connect the client socket to the server endpoint
  $clientSocket->connectTo(endpoint: $serverEndpoint);

  // Send data to the server
  $clientSocket->write(data: "Hello, Server!");

  // Close the client socket
  $clientSocket->close();

} catch (SocketError $e) {
  printf("Socket Error: %s\r\n", $e->getSocketErrorMessage());
}
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3.0
- [jetbrains/phpstorm-attributes](https://github.com/jetbrains/phpstorm-attributes) &gt;= 1.0

Installation
------------

[](#installation)

```
composer require antibiotics11/net-socket:dev-main
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/75349747?v=4)[ANTIBIOTICS](/maintainers/antibiotics11)[@antibiotics11](https://github.com/antibiotics11)

---

Top Contributors

[![antibiotics11](https://avatars.githubusercontent.com/u/75349747?v=4)](https://github.com/antibiotics11 "antibiotics11 (20 commits)")

### Embed Badge

![Health badge](/badges/antibiotics11-net-socket/health.svg)

```
[![Health](https://phpackages.com/badges/antibiotics11-net-socket/health.svg)](https://phpackages.com/packages/antibiotics11-net-socket)
```

###  Alternatives

[hisune/echarts-php

A php wrapper for echarts javascript libraries

330208.8k5](/packages/hisune-echarts-php)[giacocorsiglia/stubs-generator

Generate stubs from any PHP code for IDE completion and static analysis.

26127.7k12](/packages/giacocorsiglia-stubs-generator)[astrotomic/php-deepface

A PHP adapter for the python deepface framework.

5410.1k11](/packages/astrotomic-php-deepface)[pantheon-systems/wordpress-composer

WordPress for Pantheon with a composer.json file.

13129.8k7](/packages/pantheon-systems-wordpress-composer)

PHPackages © 2026

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