473,549 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket connection issue

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($add ress, $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
2 1889
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($add ress, $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.publi c.* 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
On Fri, 18 Apr 2008 14:57:44 -0400, Charles Calvert <cb***@yahoo.co m>
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($add ress, $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.publ ic.* 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2419
by: flupke | last post by:
Hi, I have a gui (made in wxPython) that enables a user to connect to a server and issue some commands. The problem occurs when i try to disconnect the client. It exits but it doesn't return to the prompt. I have to push Ctrl-C in order to have it exit completely. The GUI is closed though. This is a piece of code from the main class that...
6
961
by: Dan | last post by:
I am working with the C-API to MYSQL Ver 12.16 Distrib 4.0.5a-beta, for pc-linux (i686). I have noticed the following problem. Within my C program I issue --- conn = mysql_init(NULL); conn = mysql_real_connect(conn,"localhost",...etc...); if (conn == NULL) {
1
16416
by: Dr. J | last post by:
I have an application that opens a socket and connects to another application listening over a port. The problem I am encountering is that when the listening application is closed my application cannot detect it to take appropriate action. I am using "Connected" property of the Socket class, but it seems this property does not reflect the...
1
17534
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to another program for information passing. Upon receiving a particular "command" from the the information passing program, myProblemProgram will...
5
15702
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable to read data from the transport connection" when restart reading the stream with socket.BeginRead in the Sub SocketIncomingMsg. I'm debugging now for...
6
2835
by: Sean | last post by:
Hi Everyone, My apologies for a somewhat dump question but I am really stuck. I have been working on this code for two days straight I am dont know what is wrong with it. when I run the code, All I get is Input: and the program quits. I also tried reading this online but I didn't quite get it. What is the diff between sin_addr and...
5
12756
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for more incoming connections and does the BeginAccpet() again. It does an infinite loop this way. My question is: What is the best way to stop this? ...
2
3651
by: manasap | last post by:
Hi all! I've written a server and a client application using asynchronous sockets.The client sends data packets for every 7 seconds.The server receives the packets. This process proceeds smoothly without any errors but,sometimes I get the following error. "An existing connection was forcibly closed by the remote host." Why is...
2
3413
by: Nicolas Le Gland | last post by:
Hello everyone here. This is my first post in this newsgroup, I hope I won't be to much off-topic. Feel free to redirect me to any better group. I am getting strange timing issues when failing to asynchronously connect sockets on closed or filtered ports, but I'm quite unsure if this is a PHP issue or my misunderstanding, as it seems...
3
3041
by: A. W. Dunstan | last post by:
I'm creating a socket as follows: m_networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_networkSocket.LingerState = new LingerOption(true, 1); m_networkSocket.Blocking = true; m_networkSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true);...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.