SFML community forums
Help => Network => Topic started by: EiTkoCaT on July 09, 2011, 04:32:27 pm
-
Hey,
So there is this code to listen to any UDP client, but is there a way to do Socket.Receive with an exact IP?
Thanks.
-
No. You receive from everyone on a given port, and then you filter/dispatch/whatever according to the source address.
-
Hmmm, but what id I'm gonna have 2 clients using the same WiFi -> same IP?
-
2 PC belonging to the same local network can't communicate with the public internet with the same address on the same port. This is impossible. They'll have the same address (the router's one) but they'll have to use two different ports -- that's how the router knows to which PC messages coming from the outside must be forwarded.
-
Ok, but my question is - when sending from the player to the server, 2 players using the same WiFi, how can I know what client is what?
-
You can for example assign each player its own ID, instead of relying on IP address.
-
OK so I have a problem - in my server I'm sending and getting UDP packets from clients, but if I tried 2 clients using the same IP (same router),it ends up with 1 client getting the packets of both of them. How can I solve that?
-
OK so I've figured that I've got to bind to port 0 on the client, but how can I know what port to send in the server?
Thanks!