#!/usr/bin/php
<?php
# Count from 1 to 10 with a sleep
for ($count = 1; $count <= 10; $count++) {
echo $count . "\n";
usleep(500000);
}
?>
$ websocketd --port=8080 my-program
var ws = new WebSocket('ws://localhost:8080/');
ws.onmessage = function(event) {
console.log('Count is: ' + event.data);
};