Re: How do I force my script to exit after 5 seconds?

From: Date: Fri, 23 Feb 2007 20:55:12 +0000
Subject: Re: How do I force my script to exit after 5 seconds?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-249323@lists.php.net to get a copy of this message
On Thu, February 22, 2007 9:06 am, Aaron Gould wrote: > So, my question is: how can I force this script to stop after 5 > seconds > has elapsed? > > Here's the script: Inlined code might work... > ============================================================ > $fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5); > > if (!$fp) { > echo 'Error...'; > } else { > $command = "KPRINT\r\n"; > > fwrite($fp, $command); > $last_data = time(); > while (!feof($fp)) { > $buffer = fgets($fp, 1024); if (strlen($buffer)) $last_data = time(); if (time() - $last_data > 5){ fclose($fp); exit; } > } > > fclose($fp); > } > ============================================================ -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#249323) next »