Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Network
»
Multiple UDP Clients
Print
Pages: [
1
]
Author
Topic: Multiple UDP Clients (Read 4035 times)
0 Members and 1 Guest are viewing this topic.
EiTkoCaT
Newbie
Posts: 47
Multiple UDP Clients
«
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.
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Multiple UDP Clients
«
Reply #1 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.
Logged
Laurent Gomila - SFML developer
EiTkoCaT
Newbie
Posts: 47
Multiple UDP Clients
«
Reply #2 on:
July 09, 2011, 04:46:32 pm »
Hmmm, but what id I'm gonna have 2 clients using the same WiFi -> same IP?
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Multiple UDP Clients
«
Reply #3 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.
Logged
Laurent Gomila - SFML developer
EiTkoCaT
Newbie
Posts: 47
Multiple UDP Clients
«
Reply #4 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?
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Multiple UDP Clients
«
Reply #5 on:
July 09, 2011, 10:43:31 pm »
You can for example assign each player its own ID, instead of relying on IP address.
Logged
Laurent Gomila - SFML developer
EiTkoCaT
Newbie
Posts: 47
Multiple UDP Clients
«
Reply #6 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?
Logged
EiTkoCaT
Newbie
Posts: 47
Multiple UDP Clients
«
Reply #7 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!
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Network
»
Multiple UDP Clients