Re: Socket connection issue



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.


.



Relevant Pages

  • Re: Socket connection issue
    ... It opens a socket connection to a process ... I copied the scripts over to another computer that's running IIS/PHP ... is not listening. ... Use netstat to see if your end point is listening on address 127.0.0.1, ...
    (comp.lang.php)
  • Re: netstat shows LISTENING on my client-side socket as well as ESTABLISHED?!
    ... designed" then I'd have to suggest that the design is flawed. ... Can someone tell me what *user* of NETSTAT ... , a LISTENING ... LISTENING state for a client socket. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, although there's not been the usual ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)
  • Re: !EventConnect Problem
    ... poll time of 500mS we get a break in communication approx once a day, ... The socket is not in a listening state. ... There's a problem with the connection address, ...
    (microsoft.public.windowsce.app.development)