×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Simple game for 2 to run over network.

Simple game for 2 to run over network.

Simple game for 2 to run over network.

(OP)
Some time ago I created a simple game for 2 players in VB6.
(basically a VB version of the Connect4 game.)
I no longer have the code so I'm going to re-write it in VB.net but was wondering how to make it playable for 2 users across a network.
It isn't for any commercial gain, just for my own interest and also to help my son into programming - when he leaves school this summer he will go on to start a Software Development course at college in September.

Any help would be appreciated.
 

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.

Where would we be without sat-nav?

RE: Simple game for 2 to run over network.

(OP)
Thanks - I'll have alook on there.

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.

Where would we be without sat-nav?

RE: Simple game for 2 to run over network.

To setup the network communication you will need to learn socket programming.  The network communication would be done through the winsock API.  In VB.net the API is exposed through the System.Net.Sockets namespace.  Tutorials for the technical details of using the interface can be found on Google.

I suggest using a TCP connection for communication between the 2 computers.  I guess you will need you add a setup page to the game where you would enter if the computer is acting as a client or server.  The server would listen for a connection request from any other computer.  The client would also need to know the IP address of the server computer so it knows where to connect.  I think the general rule of thumb is you can use any port number over 50000 for this type of application.

 

RE: Simple game for 2 to run over network.

There are quite a few comms mechanisms between 2 machines.  You could use

1) sockets by UDP.  If the packets are small, they normally work fine.  Basically you make up your own protocol.
2) sockets by TCP - as suggested.  Again, you make up your own protocol
3) mailslots - this is a very simple mechanism which is used in the net send command.  It is available on all versions of windows so you can even play someone on W3.1!  This is similar to sockets but at a slightly higher level and a lot easier to program.
4) RPCs - remote procedure calls.  This is fairly complex and not very easy to debug

With 1 & 2, it is no different to sending stuff over a serial port.  The thing to note is that if you are testing it on one machine, use a broadcast address (last octet is 255 if it is a LAN) otherwise the packets don't get reflected off the switch and only one app gets to read the traffic.  The other alternative is to use multicast.

Not many people know about mailslots.  I only stumbled across them by accident 10 years ago - they'd been around for a very long time.

 

RE: Simple game for 2 to run over network.

(OP)
Thanks guys, I'll look into these when I finally have time to write the program.

bc.
2.4GHz Core2 Quad, 4GB RAM,
Quadro FX4600.

Where would we be without sat-nav?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources