Saturday, July 07, 2007

Proof of Concept

I tried to host an on-line game in Four Winds Mahjong tonight. One player got in fine, one player could see that the game existed and get updates, but couldn't join, and one player couldn't see anything at all. We'll call it a .500 batting average, but at least we know that it works in theory. (And I have the saved game to prove it!)

I thought I'd put up what I did on my end to make everything work; presumably everything I've done here is both necessary and sufficient to successfully play online. And of course, this comes with no warranties, either expressed or implied; I refuse to be responsible if following these directions causes your computer to launch some long-forgotten nuclear warheads.

1. HOME NETWORK. To host a game, you need to provide an IP address to the other players; presumably you can easily find out what "real" IP address you are on. However, for most of us, that IP address does not belong to the computer you're playing on; it belongs instead to your router. When packets from other players (or from the host, if you are the other players) arrive, your router needs to know to which computer to send them (especially since, unlike HTTP packets, they're not usually sent in response to anything you did). For that reason, you should configure your router so that it sends these things to your local computer. The easiest way to get your local IP address specific to the computer on which you are playing is to run "ipconfig" from a command prompt; your local IP address will almost always start "192.168." Then open your router configuration page (if you've just run ipconfig, your router address will be listed as the local gateway)--you're going to need to know your router login and password! You're looking for something called "port forwarding" or "port range forwarding" or something similar--in my router config page it's under "Applications & Gaming". If your router knows about the CVMMON service, that might be all that is needed; otherwise, you should forward ports 2300 to 2400, 6070 to 6080, and maybe 47624 to that local IP address. (I got those ranges from the help files inside Four Winds.)

Of course, if you only have one machine and no router, then you don't care about all that. And if all that seems intimidating, and you don't have anyone else in the house to yell, you can yank the wire out of your router and plug it into your computer temporarily. I had originally thought that only the host had to bother with this, but since the one player who did get in isn't on a home network and the two players who were on a home network had troubles, I'm guessing everyone has to.

2. FIREWALLS. Firewalls vary greatly, but generally you'll need to make your firewall program aware of the application ("4Winds2") and the port ranges (above) and allow access. Setting up the port forwarding above bypassed the firewall built into my router, which you would expect. As for your computer's firewall, if you just run the application and try to connect, the firewall will usually pop up a message and ask you to give a thumbs-up or a thumbs-down. You should be sure to allow both inbound and outbound connections. Just to be sure, I went into my firewall program (McAfee) and specifically opened the ports under the system services setting (it asks for the program name, and inbound and outbound ports). There should be something similar in other firewalls. I do not recommend just turning off the firewall; this way keeps some control over which programs come knocking on which ports. If your firewall is cheap (or overly complicated), you may not have much of a choice, though. If you do turn it off, be sure to turn it right back on after you're finished. Also, I turned off automatic updating of my anti-virus and firewall (not the programs themselves, just the updates) because I've found those really kill my connection when they kick in and that's not polite when you're the host.

As an optional alternative, you could find the IP addresses of your other players and add them to your whitelist of trusted IPs that connect with your computer as they please. Again, afterwards you should probably remove them (with DHCP you can't guarantee those IP addresses are always going to be associated with the nice people you play mahjongg with).

3. FIND THREE GULLIBLE PEOPLE WHO ACTUALLY THINK YOU KNOW WHAT YOU'RE DOING. And that's really it, as far as the technical details go. That's all I did, anyway, and it worked (more or less). If all this works for you, then great! If it doesn't, I don't know, because this is what worked for me. But it shouldn't be too much more complicated than that. In theory.

No comments: