By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,215 Members | 1,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,215 IT Pros & Developers. It's quick & easy.

Socket connection issue

P: n/a
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);
For experimental purposes, I copied the scripts over to another
computer that's set up with IIS/PHP in Windows Vista Business. The
socket fails to connect. After much 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.

Any ideas as to why this is happening? Is it something to do with the
Vista OS? Or do I have something mis-configured?

And, BTW, the value of $_SERVER['SERVER_NAME'] is correct. And, both
of these computers are operating on my own LAN.
Jun 2 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Fri, 18 Apr 2008 10:09:17 -0700, Martin <ir************@gmail.com>
wrote in <19********************************@4ax.com>:
>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);
For experimental purposes, I copied the scripts over to another
computer that's set up with IIS/PHP in Windows Vista Business. The
socket fails to connect. After much 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.
Open a command window on the Vista box and try to ping by both IP and
hostname. If pinging by hostname fails, then you have a DNS issue,
not a php issue. In that case, I'd suggest heading over to
microsoft.public.* and asking in a Vista group.

If pining by hostname works, perhaps it is the port that is blocked?
Check the settings in the Vista box's firewall.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
Jun 2 '08 #2

P: n/a
On Fri, 18 Apr 2008 14:57:44 -0400, Charles Calvert <cb***@yahoo.com>
wrote:
>On Fri, 18 Apr 2008 10:09:17 -0700, Martin <ir************@gmail.com>
wrote in <19********************************@4ax.com>:
>>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);
For experimental purposes, I copied the scripts over to another
computer that's set up with IIS/PHP in Windows Vista Business. The
socket fails to connect. After much 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.

Open a command window on the Vista box and try to ping by both IP and
hostname. If pinging by hostname fails, then you have a DNS issue,
not a php issue. In that case, I'd suggest heading over to
microsoft.public.* and asking in a Vista group.

If pining by hostname works, perhaps it is the port that is blocked?
Check the settings in the Vista box's firewall.
Thanks Charles.

I tried what you suggested. Pinging works ok both way - IP address and
ComputerName.

You're probably correct in that something in Vista is blocking the
port. I'm not running the firewall at all. I've looked around in the
various settings in Vista but have been unable to find anything. I'll
keep digging and see if I can find anything. (stuff is buried pretty
deep in Vista)

Thanks for the tips.

Jun 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.