Its syntax is: int fsockopen (string host, int port [, int errnumber [, string errstring [, int timeout]]])
errnumber and errstring return error information specific to the attempt to connect to the host.
<?
function get_the_host($host,$path) {
$fp = fsockopen($host, 80, &$errno, &$errstr, 30);
socket_set_blocking($fp, 1);
fputs($fp,"GET $path HTTP/1.1\r\n");
fputs($fp,"Host: $host\r\n\r\n");
$x = 1;
while($x < 10) :
$headers = fgets($fp, 4096);
print $headers;
$x++;
endwhile;
fclose($fp);
}
get_the_host("www.java2java.com", "/");
?>
|