znframework / package-socket
ZN Framework Socket Package
8.21.0
2025-01-05 13:54 UTC
Requires
- php: >=7.0.0
- znframework/package-zerocore: >=6.0
README
Follow the steps below for installation and use.
Installation
You only need to run the following code for the installation.
composer require znframework/package-socket
Documentation
Click for server documentation of your library.
Click for client documentation of your library.
Example Usage
Basic level usage is shown below.
<?php require 'vendor/autoload.php'; # File: server.php $socket = ZN\Socket\Server::run('tcp', '127.0.0.1', 8080); $socket->live(function($socket) { switch( $socket->read() ) { case 'exit' : $socket->write('Goodbye!'); return; case 'write': $socket->write('Run write command.'); break; case 'read' : $socket->write('Run read command.'); break; default : return; } }); # File: client.php $socket = ZN\Socket\Client::run('tcp', '127.0.0.1', 8080); $socket->write($command); echo $socket->read();