您的位置:程序门 -> web 开发 -> asp



asp中有什么方法可以代替php的fsockopen函数


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


asp中有什么方法可以代替php的fsockopen函数[已结贴,结贴人:jiangzheng3]
发表于:2007-01-13 14:00:08 楼主
主要是伪装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;
}
发表于:2007-01-13 14:00:451楼 得分:0
自己先顶
发表于:2007-01-13 14:12:192楼 得分:50
asp没有socket函数, xmlhttp.setrequestheader伪装不成功,说来听听有什么问题?
发表于:2007-01-13 14:39:203楼 得分:0
提示  
error:   can   not   access   from   browser
发表于:2007-01-13 14:40:274楼 得分:0
function   httppostconnect(host,path,fieldarray)  
port=80
        if   isobject(fieldarray)     then
        body   =   encodefields(fieldarray   )
        else
        body   =   " "
        end   if
        xlen   =   len(body)
        if   xlen   >   1   then
      hmot   =   "post "
      hx       =   "content-type:   application/x-www-form-urlencoded "   &   mbr
      lx       =   "content-length:   "   &   xlen   &   chr(10)   &   mbr   &   body
else
      hmot   =   "get "
      hx       =   " "
      lx       =   " "   &   mbr   &   body
end   if
hbod   =   hmot   &   "   "   &   path   &   "   http/1.0 "   &   mbr   &   "host:   "   &   right(host,len(host)-7)   &   mbr   &   "accept:   */* "   &   mbr
hbod   =   hbod   &   "accept-language:   en-us,zh-cn;q=0.5 "   &   mbr   &   hx   &   "proxy-connection:   keep-alive "   &   mbr   &   lx

set   http=server.createobject( "msxml2.xmlhttp ")
http.open   hmot,host   &   path,false
http.send(hbod)
result   =   http.responsetext
                  httppostconnect   =   result
end   function
发表于:2007-01-13 14:41:175楼 得分:0
mbr     =   chr(13)

:)
发表于:2007-01-13 17:02:376楼 得分:50
我觉得写个socket的动态库更好一些,在asp调用
发表于:2007-01-13 18:04:367楼 得分:0
多谢楼上的朋友,呵呵
发表于:2007-01-14 21:13:418楼 得分:50
哪位大哥能不能告诉我怎么开始学习asp技术
发表于:2007-01-14 21:22:399楼 得分:50
自己定议一个function


快速检索

最新资讯
热门点击