Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've written an httpPlatformHandler web app. IIS launches my program and passes a port number to listen on. My app listens on the port and handles requests, using the Winsock send function to return requested data.

One of my end users set it up on two separate servers. They tell me that only one works if the two servers are on the same subnet.

Since I don't have exact error messages and I am using an obscure language (PowerBuilder), below is a simplified version of my code. I'm hoping a Winsock guru will be able to make suggestions.

What I have tried:

WSAStartup(257, str_wsadata)

hints.ai_family = AF_INET
hints.ai_socktype = SOCK_STREAM
hints.ai_protocol = IPPROTO_TCP
hints.ai_flags = AI_PASSIVE

iResult = GetAddrInfoW(NULL, ServiceName, hints, pResult)

CopyMemory(result, pResult, StructSize)

ListenSocket = socket(result.ai_family, result.ai_socktype, result.ai_protocol)

iResult = bind(ListenSocket, result.ai_addr, result.ai_addrlen)

FreeAddrInfoW(pResult)

iResult = listen(ListenSocket, SOMAXCONN)

... a forever loop with select/accept/recv/send
Posted
Updated 10-May-23 11:41am

1 solution

If I understand this correctly :
Quote:
They tell me that only one works if the two servers are on the same subnet.
The problem could be communication is being blocked by the subnet mask settings on the NICs in the two machines. Here is something that explains what they are : What is a Subnet Mask?[^].

If you want to them to be able to talk to each other when they on different subnets then you have to set the masks on both machines to enable that. For private networks, such as a class A subnet where the first octet of the address is 10, then the masks will need to be something like 255.0.0.0 to enable them to talk to each other. If it's a class C subnet with addresses that start with 192.168 then the masks will need to be 255.255.0.0. It's a little weirder with a class B subnet but I'll leave that for you to figure out if you need to.

You might have a different issue but I have seen this exact problem caused by this issue many times in the past.
 
Share this answer
 
Comments
Roland M Smith 10-May-23 23:45pm    
I'm pretty sure it is a configuration problem on their end. I have it running on three machines on my home network without issues.

The multiple instances of my app don't communicate with each other. Each instance is only communicating with the copy of IIS running on the same machine.

Do you see anything wrong or missing in the pseudo-code I posted?
Rick York 11-May-23 11:30am    
The code looks OK. If you have it working on one set of machines you have pretty well verified it is OK. Note that on your home network you are likely to have all machines on the same subnet, usually the class C subnet, so that tends to reinforce my hypothesis.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900