znframework / package-socket
ZN Framework Socket Package
1.1.3
2023-08-01 10:57 UTC
Requires
- php: >=7.0.0
- znframework/package-zerocore: >=6.0
This package is auto-updated.
Last update: 2024-10-30 01:27:36 UTC
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();