Search code examples
socketsnetwork-programminglanchatroom

Create multiple chat rooms in LAN


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.


Solution

  • 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.