|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-12-28 12:31 UTC] l0cky at sn0wmen dot fsnet dot co dot uk
A simple query to a server with fsockopen() won't timeout if the requested server is down. $serverquery = fsockopen($host, $port, &$errno, &$errstr, $timeout); The operation times out first (120 seconds), even if $timeout is as low as 1 second; it works fine if I remove unavailable servers from the query list. Sometimes the server crashes if I try the function again before the last operation times out. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
well, me too! os: win xp professional apache 1.3.22 php 4.1.1 (win32) the code: $fp = fsockopen($hname,139, &$errno, &$errstr,3); if(!$fp) echo "$hname is not responding on port 139 "; else { echo "$hname is alive"; fclose($fp); } the problem: the 3 secs timeout does not workSystem: RedHat Linux PHP 4.0.6 I'm specifying a timeout of 0.2 seconds, but the fsockopen() function is taking as long as 3-4 seconds with slow domains (I know www.krasnapolsky.sr to be slow). This example took about 3.6 seconds. CODE: echo microtime(); echo fsockopen("www.krasnapolsky.sr", 80, &$errno, &$errstr, 0.2); echo microtime(); echo "Error Number = $errno, Error String = $errstr"; RESULT: 0.39859300 1016822517 Resource id #1 0.04482100 1016822521 Error Number = 0, Error String = So the socket is opened -- it just took way longer than I intended to allow it.