Multiple clients behind one ip

Started by
7 comments, last by DividedByZero 14 years, 1 month ago
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
Advertisement
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.
Ron AF Greve
The source port will be different: that's how you can tell the difference between the two clients.
Cheers, so i can just about ignore it while using Basic client-server system.

JamesCobras
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).
enum Bool { True, False, FileNotFound };
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.

Ron AF Greve
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)
enum Bool { True, False, FileNotFound };
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.
Ron AF Greve
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.

This topic is closed to new replies.

Advertisement