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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to