Bug #16261 Updated: fsockopen() does not allow milisecond timeouts
| From: | jroberts at forumone dot com | Date: | Mon, 15 Jul 2002 16:34:46 +0000 |
| Subject: | Bug #16261 Updated: fsockopen() does not allow milisecond timeouts | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14228@lists.php.net to get a copy of this message | ||
ID: 16261
Updated by: jroberts@forumone.com
Reported By: jroberts@forumone.com
Status: Open
Bug Type: Sockets related
Operating System: Linux
PHP Version: 4.3-dev
New Comment:
Thanks Jason. Would it be possible/desireable to include the time for
DNS lookup in the timeout period? I'm using sockets to request headers
for remote files (PDF, etc.) to display size/type in a distributed
library. In cases where I'm showing 10-20 files per page, a delay of
more than 0.5 seconds or so each is major problem -- regardless of
whether it's caused by DNS lookup or response from the actual server.
In those cases I'd rather just show a "filesize unknown" message rather
than waiting an indeterminate amount of time for the content-length
header.
Previous Comments:
------------------------------------------------------------------------
[2002-07-15 09:46:48] jason@php.net
This behavior does not actually exist in the version you report. The
test domain you are using is slow on the DNS lookup, which does not
count against the timeout.
The current development branch does not allow subsecond timeouts, and
as such I am modifying this bug to apply.
-Jason
------------------------------------------------------------------------
[2002-03-25 09:58:52] jroberts@forumone.com
BTW, socket_set_timeout is working fine for me after the socket has
been opened. It's the failure to timeout on the actual fsockopen()
that is causing issues.
------------------------------------------------------------------------
[2002-03-25 09:55:46] jroberts@forumone.com
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. Setting the timeout to an integer (e.g. 1) does not work
either (although the documentation says it can be of type float).
I reported this previously under bug 14740, but that thread was related
to win 98 and 2k, where the timeout is not expected to work.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16261&edit=1