Ever 60 seconds, I wish to perform some other routine. During this event, I also wish to take the opportunity to reestablish connection if it drops for whatever reasons. How can this be accomplished?
<?php
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, "123.321.123.321" , 20);
socket_listen ($sock , 10);
while (true)
{
//Do some other routine ever 60 seconds
$client = socket_accept($sock); //Blocking function!
$input = socket_read($client, 1024000);
$response=processInput($input);
socket_write($client, $response);
}