LAN Games

BlitzPlus Forums/BlitzPlus Beginners Area/LAN Games

Kyler(Posted 2007) [#1]
does anyone know where i can find tutorials to make LAN games or programs? i dont know anything about it but i wanted to give it a try. even a program where you chat would be okay. thnx


semar(Posted 2007) [#2]
I have a tutorial - with source - on the Code Archive, wich may be useful for you. It's a complete TCP Chat program, which works in a LAN or in Internet.

You may even use a single PC to test it, providing the right IP address and port to both Client and Server code.

Choose a free port number, and also make sure that your firewall allows to open it, otherwise won't work.

Here is the link:

http://www.blitzbasic.com/codearcs/codearcs.php?code=28

Sergio.


Kyler(Posted 2007) [#3]
doesnt work...duplicate variable on line 142. am i doing something wrong?


semar(Posted 2007) [#4]
Hi Kyler,
the code in the tutorial is tested and should work flawlessy.

Please check that you don't run both client and server code in the same IDE tab !

The client code and the server one are two separate programs, and can't cohesist together in the same editor !

Try this: open the Blitz Ide, and create two files in it; save the first as client.bb, and the second as server.bb.

In the client.bb tab, paste only the Client source code from the tutorial.
In the server.bb tab, paste only the Server source code as well.

Note: when you paste code, it works better when you do it with mouse_right_click-->paste, or from menu edit-->paste, because if you use CTRL-V, the font will be messed up.

Provide a valid IP address and a valid usable port in both source code, and then compile both programs; you should have then client.exe and server.exe.

Run both, and it should work. Alternatively, run the server.exe, and then run the client.bb from within the Blitz IDE.

Hope it helps,
Sergio.


Kyler(Posted 2007) [#5]
oh oops, copied and pasted the whole code. thnx. but i have another problem. the client wont connect to the server. they are connected (wirelessly), and firewalls are off. wats wrong?


semar(Posted 2007) [#6]
1) Can the client 'see' the server ? I mean, if you open a DOS window, and type Ping followed by the IP address of the server, do you get an answer ?

2) did you try the code on each PC ? If the code works on a PC, it should also work between two different PCs.

First, try BOTH the client and server on a same machine, and make sure it works. Make the same test on the other PC, and make sure it works on it too. Only then, try to sort out the connection between the two PCs.

Things to be careful with:
- choose a port which could be opened on each PC
- get the right IP address of the server, and use it in the client code.

Again, the code is tested in various scenario, thus it should work also on your PCs, providing a working network and valid port and IP address.

Hope it helps,
Sergio.