Sign in to follow this  
dphoenix

Writing a Linux Peer to Peer Game in C/C++

Recommended Posts

Good morning everyone, I am writing a peer to peer game for Linux/Windows, using Cygwin on Windows. I have computers connected on a local area ethernet network via a hub, and I've been practicing writing network code with this setup. I've found a few tutorials on server-client in Linux, namely this one: http://www.linuxhowtos.org/C_C++/socket.htm But I need to know how to do a peer-to-peer network setup. Specifically, in this tutorial it is assumed that the server knows the port/IP of the client. But I need to know how to have a peer discover other peers on the network, when there aren't any constant nodes to bootstrap from. My initial thoughts are that I would need them all to be constantly listening for messages at first, like the server does. The model is that a player starts the game, sets up his characters stats/etc, and then checks to see if anyone else is on the game network, and sends out a message to all the other nodes its found that the player is ready to engage in battle. Any good tutorials or tips on this? Thanks!

Share this post


Link to post
Share on other sites
The Forum FAQ has some links on the topic. There are some libraries you can use, like Rendez-Vous from Apple, or you can go it alone, typically by using UDP broadcasts. These only work on the local subnet, though -- there's no reliable way to discover potential peers on the open internet without having some kind of common server (DNS or game list server).

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