SFML community forums

Help => Network => Topic started by: EiTkoCaT on July 09, 2011, 04:32:27 pm

Title: Multiple UDP Clients
Post 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.
Title: Multiple UDP Clients
Post by: Laurent on July 09, 2011, 04:43:23 pm
No. You receive from everyone on a given port, and then you filter/dispatch/whatever according to the source address.
Title: Multiple UDP Clients
Post by: EiTkoCaT on July 09, 2011, 04:46:32 pm
Hmmm, but what id I'm gonna have 2 clients using the same WiFi -> same IP?
Title: Multiple UDP Clients
Post by: Laurent on July 09, 2011, 06:47:30 pm
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.
Title: Multiple UDP Clients
Post by: EiTkoCaT on July 09, 2011, 10:10:40 pm
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?
Title: Multiple UDP Clients
Post by: Laurent on July 09, 2011, 10:43:31 pm
You can for example assign each player its own ID, instead of relying on IP address.
Title: Multiple UDP Clients
Post by: EiTkoCaT on July 10, 2011, 07:45:58 pm
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?
Title: Multiple UDP Clients
Post by: EiTkoCaT on July 11, 2011, 12:49:39 am
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!