mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00
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:
parent
81985cfa5f
commit
60e4053912
1 changed files with 10 additions and 6 deletions
|
@ -564,13 +564,17 @@ if (!$fp) {
|
|||
<title><function>socket_set_timeout</function> Example</title>
|
||||
<programlisting role="php">
|
||||
<?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;
|
||||
}
|
||||
?>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue