Sign in to follow this  
JamesCobras

Multiple clients behind one ip

Recommended Posts

Hi guys, might be a blindingly obvious question, but when you use winsock don't you send and receive from clients using ip and ports? If so how do you access multiple clients that are behind say a router and are connecting via the same port and ip to the server. How can you send packets to one and not the other. Is it the MAC address that's hidden in the TCP/IP protocol? Does winsock handle this automatically. Or is it just that clients are bound to a socket regardless of IP/Port/Behind NAT and that sending to them is a automatic task, you just send via the socket and ip and port is taken care of? Can i have some clarification on these issues please. JamesCobras

Share this post


Link to post
Share on other sites
This is taken care of by their firewall (as long as you do not send socket info in the protocol, like sending back ' I am going to connect to you on that port).

User tries to connect to your server through its firewall. Firewall masquerades (i.e. it changes the from ip address to its own address) and forwards request remembering where it send it to). When it receives the related info back it changes and forwards it to the right client pc. Every connection has its own port (even they connect to the same server port when initiating the connection), that is how the firewall keeps track of which connection is which.

If port info is communicated, the firewall has to actuall understand the protocol.

So in the end it should be transparent for you.

Share this post


Link to post
Share on other sites
To be specific: You can't have multiple servers listening to the same port when those servers are behind the same consumer NAT gateway. You can, however, have multiple clients, as long as the server is outside the NAT. This is because a TCP connection is uniquely identified by the four-tuple (source IP, source port, destination IP, destination port), and the "source port" is more or less arbitrarily allocated by the source (or, in this case, the NAT gateway).

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
... as long as the server is outside the NAT ..


In addition to that; Usually the device that does the NAT also lets you forward certain ports to a server(s) in the local network (effectively piercing a hole in the firewall). That would be the solution if your server is behind a firewall.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
The question was about multiple machines. You can't port forward a single port to more than one machine. (Unless you're talking hardware load balancer type equipment)


Did you read my post. I said that if the OP's SERVER is behind a firewall the solution would be portforwarding the port from the firewall to his server.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ron AF Greve
Did you read my post. I said that if the OP's SERVER is behind a firewall the solution would be portforwarding the port from the firewall to his server.

That pretty much goes without saying.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this