Sign in to follow this  
fd9_

[web] Creating a simple matchmaking service

Recommended Posts

Hey, I want to create a very basic matchmaking service but I'm not quite sure how to go about it. All I'm really aiming to do is maintain a list of IP's that are updated every time a new game is hosted (along with other server information, like # of players, ping, etc). Right now I have a very small shared hosting plan (3GB/mo) which should be plenty since all I'll be doing is reading/writing from a single text file. Am I going to need PHP or MySQL (I have limited experience with PHP), what's the easiest approach?

Share this post


Link to post
Share on other sites
If all it is is an online list where anyone can read and anyone add an entry, then yes, implementing that with PHP would be simple. You probably want to delete entries older than X, too; perhaps each time someone updates to add a new game, or if someone makes a query but you find entries that are older than some number of hours.

If you want a shared hosting plan that's $11/month and gives you 5,000 GB of transfer (and 500 GB of storage), you could try dreamhost.com. If you use my referral code, "L33TN3SS," you will get $50 off and a free domain name registration!

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
If you want a shared hosting plan that's $11/month and gives you 5,000 GB of transfer (and 500 GB of storage), you could try dreamhost.com. If you use my referral code, "L33TN3SS," you will get $50 off and a free domain name registration!

I never signed up with any of the big-name hosting companies because I don't like how they run their business.

Can you explain a little further how exactly I would update the text file located on my server using PHP? I'm pretty much clueless.

Share this post


Link to post
Share on other sites
Check out the file() function to read each line of a file into an array. You can split each field using split(), say using semicolon (;) as a delimiter.

Check out fopen(), fwrite() and rename() to rename from "filename.$tmp" to "filename." That makes the update atomic -- someone will open either the old file, or the new file, and won't see a partially updated file.

However, if you want to protect against multiple people updating the file at the same time, you have to either use a lock file with spinlocking (which scales very poorly), or perhaps better just use a database like MySQL or PostgreSQL.

Finally, I'm moving this to webdev, as it has everything to do with a web app in PHP, and very little with multiplayer programming.

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