Re: Socket connection issue



"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.

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.

.



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: 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: daemon MTA-IPv4: Problem creating SMTP socket?
    ... daemon MTA-IPv4: server SMTP socket wedged: exiting ... but it sounds like something else is using / listening on ... Try doing a netstat to see if something else is using the socket. ...
    (comp.mail.sendmail)
  • 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)