1. Go to this page and download the library: Download initphp/socket 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/ */
initphp / socket example snippets
public static function server(int $handler = Socket::TCP, string $host = '', int $port = 0, null|string|float $argument = null): \InitPHP\Socket\Interfaces\SocketServerInterface
public static function client(int $handler = self::TCP, string $host = '', int $port = 0, null|string|float $argument = null): \InitPHP\Socket\Interfaces\SocketClientInterface
public function connection(): self;
public function disconnect(): bool;
public function read(int $length = 1024): ?string;
public function write(string $string): ?int;
public function live(callable $callback): void;
public function wait(int $second): void;
public function broadcast(string $message, array|string|int|null $clients = null): bool;
public function timeout(int $second): self;
public function blocking(bool $mode = true): self;
public function crypto(?string $method = null): self;
public function option(string $key, mixed $value): self;