What is blocking fsockopen?

前端 未结 4 1543
误落风尘
误落风尘 2021-01-12 10:26

After struggling for half a day, I finally manage to get reCAPTCHA to work by converting this function:

function _recaptcha_http_post($host, $path, $data, $p         


        
相关标签:
4条回答
  • 2021-01-12 10:55

    What is in $errno and $errstr inside if(false === ...)? So, what does it output if you change to

     if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
      die ("Could not open socket, error: " . $errstr);
     }
    
    0 讨论(0)
  • 2021-01-12 11:01

    Googling for your error leads to wonder if your /etc/resolv.conf is readable by PHP. Do ls -lah /etc/resolv.conf in the bash to see if it is readable. You will get something like:

    myserver:~ myname$ ls -lah /ets/resolv.conf
    lrwxr-xr-x  1 root  wheel    20B 16 mrt  2011 /etc/resolv.conf
           ^ if there is an 'r' here it is readable. if you have '-' here, it is not.
    

    If it is not readable, try doing in the bash: chmod 644 /etc/resolv.conf to make it readable.

    0 讨论(0)
  • 2021-01-12 11:04

    I might be wrong, but you use $port = 80 in fsockopen() while in cURL case this variable is not used at all. I had same problem when tried to connect to SSL via port 80 instead of port 443; as far as I know, cURL checks SSL by default and connects accordingly.

    Also, try running cURL with CURLOPT_VERBOSE to see what it does.

    0 讨论(0)
  • 2021-01-12 11:17

    Woah,

      if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
      die ("Could not open socket");
     }
    

    That doesn't make any sense surely. Try:

        $fs = fsockopen($host, $port, $errno, $errstr, 10); // @ ignores errors
     if(!$fs) die ("Could not open Socket");
    

    Also Skype also blocks port 80 sometimes.

    0 讨论(0)
提交回复
热议问题