很想知道这个函数fsockopen的用法!!!!

解决方案 »

  1.   

    int fsockopen ( string target, int port [, int errno [, string errstr [, float timeout]]] )
    target是你要连接打开的资源URI,如"http://www.dummy.com/index.html"或“www.dummy.com/index.html”
    port是端口号,对于http通常是80,对于udp是13,smtp是25, pop3是110 etc.
      

  2.   

    fsockopen得到的是一个句炳,还要用fget或fput来收发,否则端口自然被占用因为你还没什么动作
      

  3.   

    比如:
    $fp=@fsockopen("reg.163.com",80,$errin,$errno);
    if($fp){
        fputs($fp,"GET /Service.shtml HTTP/1.0\n\n");
        $return_str=fread($fp,5000);
        print $return_str;
    }else{
        print "没有取得任何信息。";
    }