Exemple

Example #1 Socket example: Simple TCP/IP server

This example shows a simple talkback server. Change the
address and port variables
to suit your setup and execute. You may then connect to the
server with a command similar to: telnet 192.168.1.53
10000 (where the address and port match your
setup). Anything you type will then be output on the server
side, and echoed back to you. To disconnect, enter 'quit'.

#!/usr/local/bin/php -q<?phperror_reporting(E_ALL);

/* Allow the script to hang around waiting for connections. */set_time_limit(0);

/* Turn on implicit output flushing so we see what we're getting * as it comes in. */ob_implicit_flush();

function waitForChange() {//reset changed$this->changed = array_merge([$this->socket], $this->clients);//variable call time pass by reference req of socket_select$null = null;//this next part is blocking so that we dont run away with cpusocket_select($this->changed, $null, $null, null); }