Re: Socket connection issue
- From: Martin <ironwoodcanyon@xxxxxxxxx>
- Date: Sat, 04 Apr 2009 06:54:43 -0700
On Sat, 4 Apr 2009 15:23:30 +0200, "mijn naam"
<whatever@xxxxxxxxxxxxxxx> wrote:
"Martin" <ironwoodcanyon@xxxxxxxxx> schreef in bericht
news:1gtct4pqbvd697imn50urh7p4eqd5tchkk@xxxxxxxxxx
I have the following code being used in several of my PHP scripts
(it's in an include file). It opens a socket connection to a process
that's running on the same computer that IIS/PHP is running on. The OS
is Windows XPPro. This all works fine - no problems.
$portnum = 1001;
$address = $_SERVER['SERVER_NAME'];
$socket = @fsockopen($address, $portnum, $errno, $errstr, 2);
I copied the scripts over to another computer that's running IIS/PHP
in Windows XPPro - an identical setup. However, the socket fails to
connect. After some experimentation, I discovered that if I used the
server's IP address instead of the $_SERVER['SERVER_NAME'] variable,
then the socket connects just fine.
I assume with "the server's IP address" you mean the address of that other
server, the one you copied your scripts to.
Yes - that is correct.
Chances are you are not able to connect to IP address 127.0.0.1 either. If
so, $_SERVER['SERVER_NAME'] is not part of the problem, nor is 'localhost',
your host file, etc.
It is normal that a process (including PHP) cannot connect to a port which
is not listening.
Use netstat to see if your end point is listening on address 127.0.0.1, for
instance using (from a cmd.exe prompt):
netstat -a -n -p tcp
Perhaps the process is listening to all IP addresses (0.0.0.0) on one
computer, and only to one or some addresses (but not 127.0.0.1) on the other
?
If this is indeed the case, then your problem is not PHP related. You need
to find out why that other process is not listening on localhost.
Well, I know the "other process" is listening. (I wrote the other
process so I have some code in it that displays the status of the
socket). Now, whether it's listening on 127.0.0.1 I'm not sure. I'll
have to see if I can figure that out.
.
- References:
- Socket connection issue
- From: Martin
- Re: Socket connection issue
- From: mijn naam
- Socket connection issue
- Prev by Date: Re: Socket connection issue
- Next by Date: Re: Socket connection issue
- Previous by thread: Re: Socket connection issue
- Next by thread: Re: Socket connection issue
- Index(es):
Relevant Pages
|