🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

how to detect LAN game server

Started by
2 comments, last by wedgeboy 23 years, 1 month ago
hello.. currently i m develop a lan game which consist of client/server architecture.. i would like to implement my client side which able to detect all the LAN game servers whcih all are online....how do i implement the client side so that it can broadcast a query packet to all the LAN game server without know what the LAN game server ip add? for example, half life counterstrike LAN game, it able to refresh the LAN game list...and all the game server will appear on the list... how to implement this kind of service?
Advertisement
Any server running on the LAN has the IP address 127.0.0.1 I believe.

If you''re using Winsock I have no idea how to use it. With DPlay you just leave the IP address empty and it searches the local lan.

Ben
http://therabbithole.redback.inficad.com


Any server running on the LAN has the IP address 127.0.0.1 I believe.

If you''re using Winsock I have no idea how to use it. With DPlay you just leave the IP address empty and it searches the local lan.

Ben
http://therabbithole.redback.inficad.com


127.0.0.1 is the loopback address - the "internal" name for the local host, so has no bearing on this problem.

To send/receive messages to/from the broadcast channel, you must first setsockopt() with the SO_BROADCAST option. The client must send a UDP message to the broadcast address (and a specific port), which is assigned the symbol INADDR_BROADCAST. The server must bind to INADDR_ANY and the specific port. It may be wise to use SO_REUSEADDR, since there may be more than one server per host. The server will then receive this message as normal and can use the from address to send back a reply.

Note that broadcast isn''t the only (or necessarily best) option. Multicast does the same job but the packets are filtered at a lower layer, saving processes not interested in your message from inspecting it.

This topic is closed to new replies.

Advertisement