Fixed example as per Andrei

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@31044 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Ron Chmara 2000-08-24 08:04:54 +00:00
parent 81985cfa5f
commit 60e4053912

View file

@ -564,13 +564,17 @@ if (!$fp) {
<title><function>socket_set_timeout</function> Example</title>
<programlisting role="php">
&lt;?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";
$fp = fsockopen("http://www.php.net", 80);
if(!$fp) {
echo "Unable to open\n";
} else {
print"Opened in less than 5 sec";
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;
}
?&gt;
</programlisting>