🎉 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!

Finding servers on multiple ports

Started by
4 comments, last by khirsah 24 years ago
Hiya, Does anyone know how I might go about implementing a "search for local servers" feature that will find servers on different ports (for running multiple servers on the one machine)? I''m currently using winsock and getting the client to broadcast a request to find servers, but this is only done on a specific port. I''ve noticed games like Quake3 seem to be able to find servers regardless of what port they''re on. Any idea how that''s done?
Advertisement
Depending on the network layers support by your local datalink, there are a couple of ways to do that. Off the top of my head:
1.) Assign a well-known broadcast port over UDP that all servers will respond to. (Or have all server broadcast on that port on intervals)
2.) IPX broadcast on the data-link on a particular socket (IPX equivelent of TCP/UDP ports are called sockets).
3.) Raw IP broadcasts. (Not recommended)
4.) (Never tried this) You can use the WinSock2 service registration calls.
I think Quake , other FPS games, and most multiplayer games use the concept of a meta server. A stable centralized information server which logs activities of game servers and their addresss. The game servers when they start up contact the meta server and following a set protocol it gets registered. Once a new player comes on, they log onto the meta server and recives a list of active game servers.

Good Luck.

-ddn
I think the best way, and possibly easiest way, would be the second part of SiCrane''s 1st suggestion.

Instead of having your client issue a broadcast query, have your servers occassionally (every 1-2 seconds, maybe less) send out some kind of small status packet containing, say, the map, number of players, game type, to a specific port at the broadcast address. Then for your client "search for local servers" feature, you can just have the list asynchronously update whenever a packet is received on that port. If a list entry sits around too long without hearing anything from that address, delete it.
Gamasutra recently had an article on networking in Half-Life and Team Fortress. They used a sytem similar to SiCrane's 2nd suggestion and Cereal Killah's fleshing out. From the main page, go to the bottom, click on [More Features...], then Programming. The article should be near the top.

Edited by - SonicSilcion on May 28, 2000 6:07:30 PM
Wow, lots of info. Thanks guys! Time to get back to work...

This topic is closed to new replies.

Advertisement