P2P network games/apps: Good choice for a “battle.net”-like matching server

前端 未结 6 1348
暖寄归人
暖寄归人 2021-02-06 10:56

I\'m making a network game (1v1) where in-game its p2p - no need for a game server.

However, for players to be able to \"find each other\", without the need to coordinat

相关标签:
6条回答
  • 2021-02-06 11:24

    An intermediate solution between hosting your own dedicated server and a strictly P2P networking environment is the gnutella model. In that model, there are superpeers that act like local servers, having known IP addresses and being connected to (and thus having knowledge of) more clients than a typical peer. This still requires you to run at least one superpeer yourself, but it gives you the option to let other people run their own superpeers.

    0 讨论(0)
  • 2021-02-06 11:28

    First, let me say that this is well out of my realm of expertise, but I found myself very interested, so I've been doing some searching and reading.

    It seems that the most commonly prescribed solution for UDP NAT traversal is to use a STUN server. I did some quick searches to see if there are any companies that will just straight-up provide you with a STUN hosting solution, but if there even were any, they were buried in piles of ads for simple web hosting.

    Fortunately, it seems there are several STUN servers that are already up and running and free for public use. There is a list of public STUN servers at voip-info.org.

    In addition, there is plenty more information to be had if you explore SO questions tagged "nat".

    0 讨论(0)
  • 2021-02-06 11:29

    how about you break the problem into two parts - make a game matcher client (that is distinct from the game), which can communicate via http to your cheap/shared webhost. All gamers who wants to use the game matching function use this. THe game matcher client then launches the actual game with the correct parameters (IP, etc etc) after obtaining the info from your server.

    The game will then use the standard way to UDP punch thru NAT, etc etc, as per your network code. The game dont actually need to know anything about the matcher client or matcher server - in the true sense of p2p (like torrents, once you can obtain your peer's IPs, you can even disconnect from the tracker).

    That way, your problems become smaller.

    0 讨论(0)
  • 2021-02-06 11:37

    I don't see any other choice than to have a dedicated server running your code. The other solutions you propose are, shall we say, less than optimal.

    If you start small, virtual hosting will be fine. Costs are pretty minimal.

    0 讨论(0)
  • 2021-02-06 11:40

    Rather than a full-blown dedicated server, you could just get a cheap shared hosting service and have the application interface with a PHP page, which in turn interfaces with a MySQL database backend.

    For example, Lunarpages has a $3/month starter package that includes 5gb of space and 50gb of bandwidth. For something this simple, that's all you should need.

    Then you just have your application poll the web page for the list of games, and submit a POST request in order to add their own game to the list.

    Of course, this method requires learning PHP and MySQL if you don't already know them. And if you do it right, you can have the PHP page enter a sort of infinite loop to keep the connection open and just feed updates to the client, rather than polling the page every few seconds and wasting a lot of bandwidth. That's way outside the scope of this answer though.

    Oh, and if you're looking for something absolutely free, search for a free PHP host. Those exist too! Even with an ad-supported host, your app could just grab the page and ignore the ads when you parse the list of games. I know that T35 used to be one of my favorites because their free plan doesn't track space or bandwidth (it limits the per-file size, to eliminate their service being used as a media share, but it shouldn't be a problem for PHP files). But of course, I think in the long run you'll be better off going with a paid host.

    Edit: T35 also says "Free hosting allows 1 domain to be hosted, while paid offers unlimited domain hosting." So you can even just pay for a domain name and link it to them! I think in the short term, that's your best (cheapest) bet. Of course, this is all assuming you either know or are willing to learn PHP in order to make this happen. :)

    0 讨论(0)
  • 2021-02-06 11:45

    There's nothing that every net connection will support. STUN is probably good, UPnP can work for this.

    However, it's rumored that most firewalls can be enticed to pass almost anything through UDP port 53 (DNS). You might have to argue with the OS about your access to that port though.

    Also, check out SIP, it's another protocol designed for this sort of thing. With the popularity of VOIP, there may be decent built-in support for this in more firewalls.

    If you're really committed to UDP, you might also consider tunneling it over HTTP.

    0 讨论(0)
提交回复
热议问题