maxfolder / unix_socket
unix socket
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/maxfolder/unix_socket
This package is auto-updated.
Last update: 2025-12-24 09:02:36 UTC
README
Unix socket server with multiple clients
Install
-
composer require maxfolder/unix_socket
-
set path to your local socket file in socket.ini example: /var/www/server.socket
Getting Started
create server.php
if (file_exists($settings['SOCK_FILE_PATH'])) {
unlink($settings['SOCK_FILE_PATH']);
}
$server = (new ServerSocketDataBuilder())
->setDomainServerSocketFilePath($settings['SOCK_FILE_PATH'])
->setProtocolFamilyForSocket(AF_UNIX)
->setTypeOfDataExchange(SOCK_STREAM)
->setProtocol(0)
->setMaxByteForRead(65536)
->built();
$server->run();
create client.php
$client = (new ClientSocketDataBuilder())
->setDomainServerSocketFilePath($settings['SOCK_FILE_PATH'])
->setProtocolFamilyForSocket(AF_UNIX)
->setTypeOfDataExchange(SOCK_STREAM)
->setProtocol(0)
->setMaxByteForRead(65536)
->built();
$client->run();
run server.php in console then client.php in another console
License
This project is licensed under the MIT License - see the LICENSE.md file for details