Solved

fsockopen fails in php script....?

Posted on 2003-11-11
4
402 Views
Last Modified: 2008-03-03

I am calling an IIS XP server from a .php script located on a different server. When I try to open a post page from PHP, I get the following error:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/mylocal/test.php on line 9

The URL i am trying to open is an IP address of my IIS server using a cable modem. This may be a permissions problem but I cant identify if it is or not. I know that the IP for my IIS is correct, it's just that the php statement cant find it. Here is the code:

<?php
$host = 'http://111.222.333.444';
$port = 80;
$timeout = 10;
$uri = '/test.asp';
       
$postData = "product_name=product1";
$length = strlen($postData);
$socket = fsockopen($host, $port, $errno, $errstr, $timeout);
if(!$socket) {
         echo '$errstr ($errno)<br>\n';
}
else
{
  // do something
}

If anyone wants the actual addresses to help me, let me know. I will email it.
0
Comment
Question by:JavaDudeIL
4 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 50 total points
Comment Utility
hi,

http://bugs.php.net/bug.php?id=11058

this page has some comments that you might want to read.. i can't suggest anything aside from this myself, other than changing the line $socket = fsockopen($host, $port, $errno, $errstr, $timeout); to $socket = @fsockopen($host, $port, $errno, $errstr, $timeout); since the error report might be more detailed echoing out the $errstr

cheers,

loz
0
 

Author Comment

by:JavaDudeIL
Comment Utility
Thanks. I assume this may in fact be an IIS issue rather than PHP bug.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now