Sign in to follow this  
jiuhu

guides on client to client programming?

Recommended Posts

jiuhu    100
Hi all, I trying to wrok on a simple c++ client to client 2 players game. I not wish to involve the server, as is just a simple 2P board game. I program with C++, but I never work on any networking's application. I try to look through the web for guides on writing a c/c application, but couldn't find any good guide. Most of the results are client / server. May I know are there any good guides for a beginner to kick start on learning to programming a client to client application? WinSock2 library will be good. Thank you. regards, JiuHu

Share this post


Link to post
Share on other sites
ollyb342    122
Hey there,

I could be completely wrong on this; but I thought that the server was simply the player which was hosting the game, and the client was the player which would connect to play with the person at the server end?

There's a plethora of Winsock2 tutorials available, just try to imagine that the server's simply the player to host the game.

Again, I may be wrong on this.

Good luck,

Ollie.

Share this post


Link to post
Share on other sites
fenghus    187
You may wish to google for "peer to peer" instead of client to client if you are searching for tutorials - it's a more common term.

Share this post


Link to post
Share on other sites
oliii    2196
If you have only two players, it's still technically a client-server architecture. one player will act the game 'server' (game host), the other the client, connecting to the game host. The game logic will be hosted by the game host, the game client will then send commands and queries to the game host (I want to move here, what's the scores, I want to end my turn, ect...).

The game host creates a game and 'advertise' the game on the matchmaking servers, the client queries matchmaking servers (usually called 'discovery'), pulls out a list of game hosts, and connect to the best game host (lowest latency.

The main problem with that server-client architecture, compare to a pure server-client (where the server is basically a dedicated server, with no rendering, sounds, ect...) is the NAT traversal, Since game hosts and clients will most likely be hosted on home broadband behind a NAT.

This is even more a problem if you go with a fully connected mesh (pure peer-to-peer, where you have several players trying to connect to each other). Some peers may not be able to connect to another peer, resulting in a 'hole'. Then you need to forward your packets through another established connection.

I would recommend you consider a 3rd party library such as RakNet that does the dirty stuff for you.

Then again if it is just on LAN, any server-client tutorial on the web should be enough (Beej networking tutorials, Gaffer's tutorials).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this