I want to create multiple chat rooms in LAN,there is a example to define my question:In WarIII,chose LAN play,when you created a play room, then everyone in this LAN will see that room is created and choose to join this one or another. So how can I create model like that when there is not a unique server to handle message as transfer station. I just thought that i may broadcast ip and port to everyone in this LAN when "create room" is pressed, but that will cause other troubles.
Asked
Active
Viewed 205 times
1 Answers
0
Sending and receiving broadcast UDP packets will work fine; but if you don't want to use broadcast for some reason, you could use multicast UDP instead. Assuming it's text chat on a LAN, that's pretty low bandwidth, so personally I wouldn't expect using broadcast to be a problem.

Jeremy Friesner
- 70,199
- 15
- 131
- 234
-
I thought again,broadcast is a solution.The trouble I mentioned is that I thought there maybe lots of broadcast triggered by listener when lots of people open or close the software or create rooms. Then I'm notified that there will be servers when the words "lots of" show up. So, is there other solutions to this question.Thank you!! – IsEE Jan 24 '15 at 15:29
-
If you want to minimize the amount of broadcast traffic, you can do so: the only time any client ever needs to send a broadcast packet is once when it first starts running, to discover who else is out there. All the other clients can respond to the broadcast packet with a unicast reply packet, and when the new client receives the replies, it can store the IP addresses that the replies came from in a list somewhere. From then on it can use those IP addresses to communicate with each client via unicast, if it wants to. – Jeremy Friesner Jan 24 '15 at 20:33
-
(but really the above shouldn't be necessary -- even if dozens of clients were sending dozens of broadcasts apiece, it's doubtful a modern LAN would have any problems dealing with it. A possible exception might be WiFi, which isn't very efficient when dealing with broadcast or multicast packets, since it has to send them at the lowest possible speed to make sure all listeners can receive them) – Jeremy Friesner Jan 24 '15 at 20:35
-
Thank you for your patience and help :) – IsEE Jan 24 '15 at 21:27