Hook me up with the network

This article will help you to connect 2 PCs using the phone, a serial cable, a local area network or the internet; we will learn how to run the battleship multiplayer clone.

The bad news
If you want to create / test / play a multiplayer game you will need 2 computers; if you have access to a single computer you won't be able to create too many multiplayer related things.

The good news
If you own a single computer you can connect to a friend's computer over the phone or (if he lives close to you) using a network cable. We will take a look at these options too.

1) I have a single computer and I want to connect to my grandmother's computer using the phone line.
You and your granny must have PCs with modems. I will use battleship as an example:

Your PC is faster so it should run as server and client.

2) I have a single computer and I want to connect to my grandmother's computer (she lives in the same building) using a serial cable.
This is the cheapest "network" because you don't need modems or network cards.

3) I have two or more computers and I want to connect them using a local area network.
This is the fastest and the most reliable network setup. I'm not going to teach you how to create a network (I would need to write a book about it) but here are some pointers:
- You need a network card in every computer that connects to the lan (local area network);
- You can use coax cable or utp cable. Coaxial cable will connect as many computers as you need without requiring extra hardware. Utp cable can connect 2 computers or (if you buy a hub) more computers;
- I ran some tests a few years ago and I found out that the speed is a little bigger (+ 20%) for coaxial cable. Other people will tell you the opposite but at least I ran some tests;
- You need to have a network protocol installed. If you can read this magazine from your computer, tcp / ip is installed and it should be enough. You can add ipx if you want but tcp / ip works ok;
- Your firewalls (software or hardware) might try to stop the acknex server or clients from communicating over the network. Allow acknex to pass through those firewalls.

Here are the network properties for two of my computers:
Let's see how we can run battleship over a lan:

4) I have a computer and I want to play battleship over the internet.
You need a computer with a modem. There are two possibilities:
a) You have a server connected to the internet all the time. If this is the case, you have a fixed IP address and you should know it so you can send it to the client that connects to you through email, etc.
b) You don't have a permanent connection to the internet and you want to use your computer as a server over the net; in this case, the IP address changes every time you connect to the internet.

Acknex uses the tcp / ip protocol by default so the steps that are needed in order to run the game are exactly like in the picture above. The problem here is to get the dynamic IP address if we're in the b) situation because we need to send it to the client using the email every time we connect to the internet. The following info was tested on Win98 and Win2000 PCs but it should work ok on Win ME and WinXP.

To get your IP address in Windows 98, Press Start -> Run, type "winipcfg" (without the quotes) and press OK. You will see the following program window:

You can see that the IP address is 0.0.0.0; this happens because this PC isn't connected to the internet for the moment. Always start your internet connection first and only after a successful connection get and send the IP address! If you have a network card installed in your PC be careful: you need to get the IP address for your PPP Adapter, like in the picture.

If you need to get your IP address in Windows 2000, press Start -> Programs -> Accessories -> Command prompt. Type "ipconfig" (without quotes) and press Enter; you should see this window:

This time I have connected to the internet first so I have got a good IP address. I need to send this address to the client that will connect to my server using an email, a messenger client, etc. All we need to know is server's IP address because the clients connect to it; if you are a client you don't need to know or to send your IP address.

Another method that allows you to get your IP address works ok on any PC, regardless of the operating system. Go to http://www.whatismyipaddress.com/ and you will see your IP address like in the picture below:

Ok, the last method can be used if you are a programmer: LocalIP returns the IP address of the local machine using the winsock activex control.

IMPORTANT INFO: The server has to run first. If the client runs before the server, it will fail to connect and all you can do is to exit and restart after the server has started to run.