Bug #14740 Updated: fsockopen() won't timeout

From: Date: Tue, 12 Feb 2002 22:13:35 +0000
Subject: Bug #14740 Updated: fsockopen() won't timeout
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214@lists.php.net to get a copy of this message
 ID:               14740
 Updated by:       jason@php.net
-Summary:          fsockopen() won't timeout
 Reported By:      l0cky@sn0wmen.fsnet.co.uk
-Status:           Open
+Status:           Analyzed
 Bug Type:         Sockets related
 Operating System: Win98 and Win2k
 PHP Version:      4.1.0
 New Comment:

The Win32 code does not set a timeout. The comment at the end refers to
there being a problm on linux, which I could not reproduce.

Winsock does support non-blocking IO, but is set up quite differently
than BSD sockets.


-Jason


Previous Comments:
------------------------------------------------------------------------

[2002-02-11 15:40:27] salvag3@netscape.net

The timeout doesn't work if the host don't respond on the
requested port :-(

os: linux redhat 7.2
php 4.0.6-7
apache 1.3.20-16

------------------------------------------------------------------------

[2002-01-28 12:19:57] korpse@p16.pub.ro

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 work

------------------------------------------------------------------------

[2001-12-29 09:20:52] l0cky@sn0wmen.fsnet.co.uk

ok to clarify.. seems like this is a common mistake

fsockopen() times out ok if the server doesn't exist.  The problem
occurs when the server doesn't understand what is sent to it afterwards
and stalls for a reply (ie, if the port is now used by another
service).

I'll check the bugs for fwrite(), fgets() etc

------------------------------------------------------------------------

[2001-12-28 12:33:49] l0cky@sn0wmen.fsnet.co.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.

------------------------------------------------------------------------

[2001-12-28 12:31:36] l0cky@sn0wmen.fsnet.co.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.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=14740&edit=1



Thread (1 message)

  • jason@php.net
  • Unknown Message
    • jason@php.net
« previous php.bugs (#214) next »