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

2007-02-23 Thread Richard Lynch
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,

[PHP] How do I force my script to exit after 5 seconds?

2007-02-22 Thread Aaron Gould
I have a script that connects to a networked device via PHP's socket functions. This device accepts proprietary commands (e.g.: KPRINT, as seen below), and returns data. However, this device does not have any sort of EXIT command to end the processing of events. So it essentially loops

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

2007-02-22 Thread Brad Bonkoski
I think something like this will work for you.. $start_time = time(); ...loop.. if( time() - $start_time 5 ) exit; -B Aaron Gould wrote: I have a script that connects to a networked device via PHP's socket functions. This device accepts proprietary commands (e.g.: KPRINT, as seen below),

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

2007-02-22 Thread Aaron Gould
I tried this earlier, but it does not seem to work... It appears to just hang when no data is returned from the networked device. It seems as if the loop stops, and is waiting for something. Brad Bonkoski wrote: I think something like this will work for you.. $start_time = time();

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

2007-02-22 Thread Brad Bonkoski
Aaron Gould wrote: I tried this earlier, but it does not seem to work... It appears to just hang when no data is returned from the networked device. It seems as if the loop stops, and is waiting for something. probably blocking on the socket have you tried:

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

2007-02-22 Thread Robin Vickery
On 22/02/07, Aaron Gould [EMAIL PROTECTED] wrote: I tried this earlier, but it does not seem to work... It appears to just hang when no data is returned from the networked device. It seems as if the loop stops, and is waiting for something.

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

2007-02-22 Thread Aaron Gould
Thanks very much, I've added stream_set_timeout functionality, and it seems to work very well! For reference, here's the modified script: $fp = fsockopen('192.168.3.25', 10001, $errno, $errstr, 5); if (!$fp) { echo 'Error...'; }