(PHP 4 >= 4.0.0)
socket_set_timeout -- Set timeout period on a socket
Description
bool
socket_set_timeout ( int socket descriptor, int seconds, int microseconds)
Sets the timeout value on socket descriptor,
expressed in the sum of seconds and
microseconds.
Example 1. socket_set_timeout() Example <?php
$fp = fsockopen("www.php.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;
}
?> |
|
This function was previously called as
set_socket_timeout() but this usage is deprecated.
See also: fsockopen() and fopen().