Connections and UI.

Started by
5 comments, last by dizzydog 19 years, 8 months ago
I'm writing my game using DirectPlay. The game itself is working fine and now I'm trying to improve the interface for making the connection. I don't want to have to setup a lobby for players to connect to each other. I was thinking that players (typicaly friends or family) would be ok with giving info to each other along the lines of "kseh.ab.telus.net" (this is a hostname, right?) to connect to each other. I was hoping to cerate a list of people the player typicaly connects to and store the host name for that person. When the player wants to connect with someone they select the person from the list, the appropriate hostname is sent to gethostbyname(), and the resulting numeric IP address is used to create the connection. All this was to resolve the problem of IP addresses being assigned by the server every time the player connects to the internet (for dialup). The problem I'm having is that I'm not sure how to get the hostname properly. I tried one function called gethostname() which gets me "kseh.ab.telus.net" on my machine but when I try it on other machines I just get the name of the computer and nothing to identify the server. If I pass in that computer name to gethostbyname() I can only find the computer if they're on the same server as me. Is what I'm trying to do impossible? If not what am I missing? If it is impossible, what else could I do to make the interface for connecting as user friendly as possible without having to create a lobby server?
Advertisement
Giving out your IP is the standard way of doing things in non-lobby multiplayer apps. What's wrong with this approach?
Well, what happens if your IP address is not static? Should a person really need to find their IP and email it to their friend every time they connect to the internet with a dial up connection? If you already have some sort of chat connection to relay this information I know that I could live with it as a player. But it doesn't seem right to require a third party program to get mine going.

Part of the reason for doing this is that I'm trying to keep this game for people who are not particularly computer savy. I'm assuming that if they're on the internet then they can deal with something that resembles an email address that doesn't repeatedly change.

If nothing else it's doing it for the sake of doing it.
You need to keep some kind of lobby available at a fixed name.

This is what services like Battle.net, or GameSpy, or X-Box Live! do: they give you a name that will "always" answer, and where you can put your lobby (but not the actual game). There's really no way around it if you want a good UI.

And, yes, this means you have to pay hosting fees. The days of free everything are happily gone :-)
enum Bool { True, False, FileNotFound };
You will want to give out a host name instead of an IP address. If you have a static IP, you can register a name with one of the many name registration services and point the name to your static ip.

If you have a dynamic IP, like running from you home cable modem, there are several services that create second level domain names. The one I use for my home connection (a cable modem) is dyndns.org. You can setup your own name like mygame.dyndns.org. They supply software that updates the IP for the name when the IP changes.
- onebeer
Is it not possible to use the domain name of your internet provider in combination with your login ID to aid in the location of your computer? Even if it's not with DirextPlay? Shouldn't I be able to get the address of my IP server and be able to let other people use that to search for anyone hosting a game?
When you get a dynamic IP address from an ISP, the hsostname associated with that IP usually has nothing to do with the user it's assigned to. A lot of ISP's will use a combination of sitecode and ip address as part of the hostname. If you get everyone to use dyndns you could setup a system like what you're doing, but otherwise it won't work because the persons hostname and IP will both change when they reconnect.

An alternative would be to tie the game in with one of the messaging systems like Yahoo or AIM, and use that to contact the person and launch the game, or just to swap IP addresses. Maybe an AIM plugin, but I haven't actually written one so dunno if it'd be a fit for what you're trying to do.

This topic is closed to new replies.

Advertisement