Jump to content
  • Advertisement
Sign in to follow this  
Lord Gzoo

non constant port?

This topic is 4825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HELLO. i was always wondering about the option to change my server's listening port on some games, or a bittorrent client for example, or anything else like that. well, i didn't really wonder about it, i more of wondered how the other side of knows what port to connect to? let's say i'm using winsock because that's the only thing i know. const int X = 27152; all of the lovely basic tutorials out there show that the servers open a socket on port X and the client connects to that same port X. so how does these games, and my bittorrent client, and my IM-client, and everything in the world, does it?

Share this post


Link to post
Share on other sites
Advertisement
Either both the server and client know the port (because it is known and fixed), or like BT, when you connect to the tracker, it tells you the IP and port of all the people connected.

Share this post


Link to post
Share on other sites
There is also the "SRV" record type in DNS, where you can register an IP address and port number for a specific name in DNS, and someone querying for that record kind will receive the tuple back.

Of course, the standard host resolver interface (gethostbyname()) doesn't let you query for SRV records, which means it's never been that popular. (In fact, it also doesn't let you query MX or any other record kind than recursively found A records...)

Share this post


Link to post
Share on other sites
Ports are either fixed for applications, or the server ports and IP are made public and stored in a server browser somewhere on the web. Since on some applications you need to know who is online and who isn't it makes sense, but it's more logistics, since you have to maintain server browsers and their mirrors. Servers like Counterstrike, Quake, ect... are made public and when you create a server, it reports itself to the server browser. Then clients query the browser for IP and port (and other stuff, like password protected, number of players, ...) to connect to a specific game. That server browser place can do much more, such as CD-key checks, storing your player profile (steam), check if your friends are online....

For IMs, I'm not sure, but I would guess they do the same. For bittorrent, I'm not familliar with it.

So, if you create an application, then you might have a problem getting people connecting to your server, if they don't know it exists, unless you maintain a database of active servers. You can't just 'search' the internet, like you would search a hard drive for a file.

Share this post


Link to post
Share on other sites
thanks for the replies
i feel wiser now (that won't be long though)

hey oliii you answered on my b/day [pig]

hmm actually not i'm on the 30 :|

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!