If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] A simple network game?

Best way to learn something is to do it, right? I decided to create a simple card game, with no AI since it’s supposed to be an online multiplayer game – an exercise/experience that could come in handy later on. The game’s just something I play with my friends when we get together, the mechanics and rules are not important here; I have no problem with implementing game logic, but the networking part is giving me some trouble. Now, I don’t need any code, I just need someone to help me understand some concepts, on a general, abstract level.

What I want is for the player to be able to create a game server (give it a name, set some game-related options, etc.) and wait for the others to connect; or to be able to connect to an existing server, that he can pick from a list. You know – like in the good ol’ Counter Strike.

I’ve started by reading some articles on simple chat applications, synchronous vs asynchronous communication, and the like. What I don’t understand is – how do I make the my program find the game servers that already exist, and what do I need to do to make a server visible to any client game looking for one? I guess I need some sort of “publicly available” or “standard” remote endpoint.
And, I must admit, although I know the basic network programming concepts, and how things are done (create server, establish a connection, send data back and forth…), I don’t have a clear understanding of some basic things about networking, since I don’t have much experience with it. For example, whether the server must have an IP of the computer it’s started on, or you can assign any IP to it, or what? I’ve read some articles on IP classes, special addresses, default network, loopback, broadcast... Do I just pick what’s suitable, or there are some mystery rules that govern this world If someone could give me a brief 101 on that… Because I think this is the main source of my problem…

Are there any tutorials or books on this topic(s) you know of?
Thanks in any case.

Re: A simple network game?

Thanks.

I did some research/reading on my own, so now I have a better understanding of this stuff. And as a consequence, I can finally keep it simple and express in a sentence or two what I wanted to say in the first place…

Here goes:
If I had a multiplayer game based on user-hosted servers, how do I make a client game find all the available servers?

Q21) How does my client find the server it wants to talk to?
--------------
There are several ways of finding the server, depending on where the client runs with regards to the server.

1) ...

3) Some clients have a hard-coded name of a "master server" which will list the actual available servers. Typically, this hard-coded name will be text form (not IP form) so that the master server can be moved (or DNS load balanced) when necessary, without patching the clients. The client will connect to the master server, get a list of available actual servers to talk to, and let the player choose (or choose for the player).

4) …

and

Q24) How do I find a server for my game? Currently, I'm hard-coding an IP address, but that won't work when I ship it to others.
--------------
If your game is "MMO" and needs a specific server back-end, register a domain name for your game, and look up your login server using a name such as "login.instance1.yourgame.com".

If your game is networked over the internet, but uses user-hosted servers, then you need a matchmaking/lobbying/introduction service. The service itself lives at a known DNS name; hosts and clients connect to this server to register/query the database of active hosted games. You may also be interested in NAT punch-through in this case; see previous questions in this FAQ.

If your game is networked over LAN, then you need to use some kind of broadcast announcement. More information can be found in this article on LAN matchmaking.

So – I need a master server, and a domain name wouldn’t hurt...
Just a few things remain unclear: Is there a way I could do this for free (using some online service, or something like that), or it would inevitably cost me?
Are there some alternative approaches?

Re: A simple network game?

I'm not saying I know the details behind it, but you could host it from your machine, or have anyone else host it and connect through IP. Lots of games connect over IP without the use of a master server. Then, your host ("server"), could update a database somewhere with the game results/stats/etc.

Re: A simple network game?

Originally Posted by TheGreatCthulhu

So – I need a master server, and a domain name wouldn’t hurt...
Just a few things remain unclear: Is there a way I could do this for free (using some online service, or something like that), or it would inevitably cost me?
Are there some alternative approaches?

I am going to say, yes, you need a domain name. Or you are going to need a static IP address from your ISP. In my experience, at least in the US, a static IP will cost you more than a domain name. You can get cheap domain names from places like GoDaddy. Although, if this is all you are going to do, it might be best to just get the domain name from Network Solutions. As for the DNS, there a quite a few places that can deal with dynamic DNS. Check out Afraid.org. This way, when the IP address changes at your ISP, it can be automatically updated, and your clients can still find you.

Re: A simple network game?

Thanks to all.
As I’ve said, it’s a card game I like to play with some friends, and I was thinking it would be great if we could play it on the net.
So, I guess I could host it on my computer, but I wanted them (or anyone else) to be able to play when I wasn’t online. On the other hand, since we would probably be the only ones who would play it, I suppose I could make it work by looking for game hosts on a few preconfigured IPs. Now that I think of it, I could have a simple game config file on each pc telling the game where to look. But, it’s an ugly solution, isn’t it?

P.S.
Mariocatch – You’re right, a solution that’s free would be much better .
Sotoasty – While running around the web looking for answers, I actually did take a look at afraid.org last night. Interesting, in their Feature List, there’s an entry saying “5 free shared hostnames, use anywhere”, and on another page:“… you are welcome to signup for your free account and create up to 5 subdomains off of the domains others have contributed and point these hosts anywhere on the Internet.”

If I understood this right, does this mean that I could have my game use something like myhome.someonesdomain.com instead of an IP? And afraid.org would take care of dynamic-IP-related issues?

P.P.S. I’ll leave this thread unresolved for a little while, maybe someone will come up with something...

Re: A simple network game?

Originally Posted by TheGreatCthulhu

Sotoasty – While running around the web looking for answers, I actually did take a look at afraid.org last night. Interesting, in their Feature List, there’s an entry saying “5 free shared hostnames, use anywhere”, and on another page:“… you are welcome to signup for your free account and create up to 5 subdomains off of the domains others have contributed and point these hosts anywhere on the Internet.”

If I understood this right, does this mean that I could have my game use something like myhome.someonesdomain.com instead of an IP? And afraid.org would take care of dynamic-IP-related issues?

P.P.S. I’ll leave this thread unresolved for a little while, maybe someone will come up with something...

You know, I forgot about that feature at afraid.org. Yes, you can setup a name on one of the public domains. So you could have

TheGreatCthulhu.someoneelsesdomain.com and you can control what IP address it points to. They have a utility that you would need to download. It runs as a tray app, and whenever your public IP address changes, it will update afraid.org with the appropriate information. This would be the perfect solution for what you would like to do.