This is the basic connection code for a small PHP IRC bot. The problem is that it seems that the while() loop does not progress beyond fgets() until it receives data from the IRC server. I want the while() loop to iterate regardless if the IRC server has not yet sent data. Is this possible?
$socket = fsockopen($config['irc_server'], $config['port']);
while (1)
{
$data = fgets($socket, 128);
echo '[RECEIVE] ' . $data;
$recv = explode(' ', $data);
if ($recv[0] == 'PING')
{
send('PONG', $recv[1]);
}
}