• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 547
  • Last Modified:

Using Fsockopen() to check host status. Times out randomly??

Hello,

I have a while loop that does the below for about 90 times to a list of addresses.  I have it printing to tables on a page, which works fine.  However, everytime I run it, it times out at a different spot, regardless of whether the host is offline, online -- which is very strange to me.  I tried using Fclose(), but it said it was invalid (not stream).  

Does anyone know the best way to check port status for about 100 IP's w/ having it "time out" ?  

I did notice it's happening at EXACTLY 30 seconds everytime... I guess I'll check the PHP.INI.

Thanks.

      $VncCheck = @fsockopen($HostName, $VncPort, $errnovnc, $errstrvnc, 1);
                                if (!$VncCheck) {
                                                $VncStatus = 'OFFLINE';
                                                $VncStatusColor = '"#FF0000"';      
                                } else {
                                        $VncStatus = 'ONLINE';
                                                $VncStatusColor = '"#33CC00"';
                                }

0
jgantes
Asked:
jgantes
1 Solution
 
jgantesAuthor Commented:
Never mind...  Just set this:

max_execution_time = 30

to

180
0
 
gruntarCommented:
Default time for script is 30 seconds. If your script is running longer you should set higher time limit
for your main script.

To do that add this at the beginning of your script

<?php

set_time_limit(500); // seconds

// your code...


?>

Cheers
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now