[UPHPU] Have a little question...

Scott Morris scott.the.elder at gmail.com
Mon Jun 13 17:38:53 MDT 2005


Could anyone possibly help me figure out why this takes so long?  It
should take less than a second, yet it takes about 30.

Sorry in advance for any wrapped lines... :|

<?

function getsock( $host, $path, $referer=""){
	$user_agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8)
Gecko/20050529 Firefox/1.0.4";
	$header="GET ".$path." HTTP/1.1\r\n";
	$header.="Host: ".$host."\r\n";
	$header.="User-Agent: ".$user_agent."\r\n";
	$header.="Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
	$header.="Accept-Language: en-us,en;q=0.5\r\n";
	$header.="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
	$header.="Keep-Alive: 300\r\n";
	$header.="Connection: keep-alive\r\n";
	if(strlen($referer)>0){
		$header.="Referer: ".$referer."\r\n";
	}
	$header.="\r\n";
	$fp = fsockopen($host,80);
	fputs($fp, $header);
	while(!feof($fp)) {
		$result .= fgets($fp, 1024);
	}
	fclose($fp);
	return $result;
}

$data=getsock( "www.google.com", "/index.html" );

echo $data;

?>

Thanks in advance.

Scott



More information about the UPHPU mailing list