Date: 08/23/00
- Next message: Mark Kronsbein: "[PHP-DOC] cvs: phpdoc /de Translators"
- Previous message: Hartmut Holzgraefe: "Re: [PHP-DOC] cvs: phpdoc /en/functions oracle.xml"
- In reply to: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions network.xml"
- Next in thread: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions network.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 23 Aug 2000, Ron Chmara wrote:
> +<?php
> +socket_set_timeout(80,5,0)
> +// set 5 second maximum for connection over port 80
> +$fp = fopen("http://www.php.net/index.php","r");
> +if (!$fp) {
> + print"Unable to open";
> +} else {
> + print"Opened in less than 5 sec";
> +}
> +?>
Uh, that example is not correct. socket_set_timeout() does not control
fopen() timeouts, but rather the timeout during reading or writing data
from or to the socket. So, you could have something like this:
$fp = fsockopen("http://php.ispi.net", 80);
if(!$fp) {
echo "Unable to open\n";
} else {
fputs($fp,"GET / HTTP/1.0\n\n");
$start = time();
socket_set_timeout($fp, 2);
$res = fread($fp, 2000);
var_dump(socket_get_status($fp));
fclose($fp);
print $res;
}
socket_get_status() will help you determine whether a timeout occurred
or not.
-Andrei
"Everything has its wonders, even darkness and silence, and I learn,
whatever state I may be in, therein to be content." - Helen Keller
- Next message: Mark Kronsbein: "[PHP-DOC] cvs: phpdoc /de Translators"
- Previous message: Hartmut Holzgraefe: "Re: [PHP-DOC] cvs: phpdoc /en/functions oracle.xml"
- In reply to: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions network.xml"
- Next in thread: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions network.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

