Client Server application with a NAT??

  • Thread starter Thread starter Grant Schenck
  • Start date Start date
G

Grant Schenck

Hello,

I have a strange issue with a client server application I developed in C#
..NET. It uses sockets but I don't see a news group that specific. If this
would be better posted in different news group then please let me know...

The problem we have is that our server is on one subnet and our clients are
on another subnet. I track the connected clients by IP address. The
problem I have is that all clients come in with the IP address of the
gateway where the NAT is running. The result is that one client can connect
but when a second client connects I see the same IP address and assume that
somehow the previous connection was not torn down and disconnect the
previous connection. The result is that only one client can connect at a
time.

This is an area I know virtually nothing about but I thought the whole point
of a NAT is to virtualize connections in such a way that applications just
work. I shouldn't have to code specially to work with clients connected via
NAT, should I?

I'm thinking this is an issue with the configuration of their NAT but I
don't know. My other concern is that somehow this is just a limitation of
client/server software where the client and server connect via a NAT and
while I assume most companies run NATs, they probably run those between the
public internet and their network, not between subnets of their network.

Any and all advice would be very much appreciated!

Thanks in advance.
 
Grant said:
Hello,

I have a strange issue with a client server application I developed in C#
..NET. It uses sockets but I don't see a news group that specific. If this
would be better posted in different news group then please let me know...

There are in fact newsgroups specific to Winsock, and even TCP/IP. The
latter being more directly topical, but even the former being more
topical than a general purpose .NET newsgroup.

That said:
The problem we have is that our server is on one subnet and our clients are
on another subnet. I track the connected clients by IP address. The
problem I have is that all clients come in with the IP address of the
gateway where the NAT is running. The result is that one client can connect
but when a second client connects I see the same IP address and assume that
somehow the previous connection was not torn down and disconnect the
previous connection. The result is that only one client can connect at a
time.

Your main problem here is that you are tracking only by IP address.
You'd have the same bug without the NAT, if you had two different
clients running from the same computer (e.g. via Terminal Server, or as
an automated process, etc.).
This is an area I know virtually nothing about but I thought the whole point
of a NAT is to virtualize connections in such a way that applications just
work. I shouldn't have to code specially to work with clients connected via
NAT, should I?

No, usually you shouldn't. There are exceptions, but this isn't one of
them.
I'm thinking this is an issue with the configuration of their NAT but I
don't know.

It's a bug in your program. You need to use both the IP address and
port number as the unique identifier for your client.

Pete
 
Thanks! I coded up based on that and am waiting to see if the fix worked.

Great tip, thanks!
 
Back
Top