asp中有什么方法可以代替php的fsockopen函数
歪歪 2007-01-13 02:02:47 主要是伪装http头的问题,郁闷的,我用xmlhttp.setRequestHeader伪装没调试成功
function HttpPostConnect($host,$path,$fieldArray=array())
{
$port=80;
if(sizeof($fieldArray) > 0) {
$body = _encodeFields( $fieldArray );
}else{
$body = "";
}
$len = strlen( $body );
$request=($body ? "POST" : "GET")." $path HTTP/1.0\r\n".
"Host: $host\r\n".
"Accept: */*\r\n".
"Accept-Language: en-us,zh-cn;q=0.5\r\n".
($body ? "Content-type: application/x-www-form-urlencoded\r\n" : "").
"Proxy-Connection: Keep-Alive\r\n".
($len ? "content-length: $len\r\n" : "").
"\r\n".
($body ? "$body" : "");
$fp = fsockopen( "$host", $port, $errno, $errdesc, 30 );
if(!$fp) return false;
fputs($fp,$request);
while(trim(fgets($fp,1024)) != "");
return $fp;
}