PHP code example of alexpts / php-transports
1. Go to this page and download the library: Download alexpts/php-transports library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexpts / php-transports example snippets
use PTS\Transport\File;
use PTS\Transport\Tcp\TcpSocket;
use PTS\Transport\Udp\UdpSocket;
use PTS\Transport\UnixSocket;
$udp = new UdpSocket;
$udp->connect('127.0.0.1', ['port' => 3000]);
$udp->write('some message');
$udp->close();
$unix = new UnixSocket;
$unix->connect(__DIR__ . '/controller.sock');
$unix->write('some command');
$unix->close();
$tcp = new TcpSocket;
$tcp->connect('127.0.0.1', ['port' => 3000]);
$tcp->write('some message');
$tcp->close();
$file = new File;
$file->connect(__DIR__ . '/log.txt', ['mode' => 'w+']);
$file->write('some message');
$file->close();