scanning lan for servers

Started by
9 comments, last by Evil Steve 15 years, 7 months ago
Quote:Original post by bencelot
That'd make sense. But why do I always see games giving the option to host on whatever port they want? What are the benefits?

Is it because some servers can't use the default port for whatever reason.. and have to use another one?

I could easily hardcode a default in.. but I'd rather not if it's going to limit the users.


Or, I suppose I could restrict it to a default only when someone wants to play LAN.. as when they play online, the game will be able to send their ip and port to a central server, which clients can download and know where to look.
Can you give an example? It sounds to me like the game would be giving the user the option to specify a port; and all clients would need to connect to that port. In that case the port is still known, it's just that the user has to say what the port is.

There's no problem in using a fixed port; that's what the majority of games out there do. That makes tech support easier among other things (You know what port they should have open on their router). The only possible problem would be if the user already has an application running on the same port, but that's pretty unlikely (You have a 1 in ~60,000 chance), and you can just give a user friendly error if that happens (bind() will fail with WSAEADDRINUSE or something).
So long as you don't use a reserved port number (<= 1024), there shouldn't be a problem.

This topic is closed to new replies.

Advertisement