I'm trying to open a socket to post data to an external site. Specifically, it will be posting securely to a payment processing site. To test the function I wrote, I'm having it post without ssl to the same domain that the script is on.

I'm getting the following error:


Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known (is your IPV6 configuration correct? If this error happens all the time, try reconfiguring PHP using --disable-ipv6 option to configure) in /pathtofile/authorizenet.inc on line 34

Warning: fsockopen(): unable to connect to :80 in /pathtofile/authorizenet.inc on line 34


Any ideas?

  • keith

    try something like this

    $fp = fsockopen ("domainname", portno, &$errno, &$errstr, 30);
    $data = "Form Data";
    if (!$fp)
    {
    echo "$errstr ($errno)<br>\n";
    }
    else
    {
    fwrite($fp,$data);
    $response = fgets ($fp,2048);
    }
    

    Good Luck
    TommYNandA

      unfortunately, your suggestion doesn't help. thaks anyway.

      my code already looks like this:
      (I should have posted it in the op)

      //open socket connection
      $handle = fsockopen($form_details['form_action'], $form_details['port']);
      if ( !$handle ){
      	return(-1);
      }//end if
      
      //send the data
      fputs($handle,$post_header);
      
      // get the response
      while (!feof($handle)){
      	$result .= fread($handle,32000);
      }//end while
      
      //close socket
      fclose($handle);
      

      and the error on fsockopen still stands.

      • keith
        Write a Reply...