[RESOLVED] A simple network game?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [RESOLVED] A simple network game?

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Posts
    1,099

    [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.

    P.S. I’m using C#, if it’s relevant.

  2. #2
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: A simple network game?

    Take a look at Microsoft's XNA library. http://www.xna.com/
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  3. #3
    Join Date
    Jan 2010
    Posts
    1,099

    Post 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?


    In the end, what enlightened me was the FAQ page on GameDev.net.

    http://www.gamedev.net/community/for...sp?forum_id=15

    So, if anyone has similar questions:

    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?

  4. #4
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,451

    Re: A simple network game?

    Quote Originally Posted by TheGreatCthulhu View Post
    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.

  5. #5
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    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.

  6. #6
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: A simple network game?

    I'd like to re-iterate, adding a simple textbox in your game that asks for an IP Address, then looks up a server at that address is a free way to get multiplayer capabilities working in your game.

    I'm just re-iterating it because it seemed like the OP wanted a free way to do write a multiplayer game.

  7. #7
    Join Date
    Jan 2010
    Posts
    1,099

    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...
    Last edited by TheGreatCthulhu; January 11th, 2010 at 11:44 AM.

  8. #8
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,451

    Re: A simple network game?

    Quote Originally Posted by TheGreatCthulhu View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center