I'm working on a PHP IRC bot. Currently I'm using a while fgets(...
loop to keep it listening for data and responding.
At some point while I was asleep, it actually "pinged out" and stopped getting data, without any sort of error message that I could use to trigger a restart.
I thought of a quick solution, and that's to store the last time the server pinged the bot, and if its more than x seconds, reconnect. This plan works great in theory, except that this ping check is done inside the while fgets loop, so it only checks it when it receives data from the IRC server. As such, if it just stops getting data from the server, it won't compare the ping times, and won't restart.
I can't think of how to get around this.