Jump to content
  • Advertisement
Sign in to follow this  

WinSock, PHP and Master Server

This topic is 4139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm totally new to network programming, but I've been doing some research in the last few days and have decided to use winsock for the multiplayer fps I'm making. One of the things I'm having trouble figuring out, is how I would get a master server set up. Since I have a slow upload speed, and very limited bandwidth, running a master server on a pc at my house isn't really an option. So I was thinking of getting some decent paid hosting, and running a server on that using php. I don't know much php, but I know you could store server information in a mysql database, and have a few different .php files for registering your server, removing your server, getting a list of active servers (which could also trim servers which haven't sent an update in X seconds). I was just wondering if this idea is plausible, and if so, how I would go about accessing the .php files, and sending data to them from my server application, and if this is possible using winSock? Thanks heaps :) -Matt

Share this post

Link to post
Share on other sites
PHP files are generators/scripts that produce some output, typically a HTML document. So you access the result of what you want as a .html we page.

What you now need to figure out is how to allow clients to register themselves. Most likely, this would be done with one of the HTTP queries.

The PHP scripts for both of those are more or less trivial.
- When a client requests registration, you look up their IP, put that into DB

- When client queries this master server, it simply downloads a html page and parses that to obtain the IPs of other clients. The script that generates this page can also use that time to check for expired IPs.

Winsock on the other hand is just implementation of TCP/IP stack. What you send over it is irrelevant. There's probably a few implementations of HTTP you could use to access the pages.

I don't know, this is a somewhat simple solution, but not particularly robust. You'd need some way to distinguish clients behind NATs, prevent spiders from registering themself as a client, you'd also have no reliable means of checking or polling clients. And tying all of this into MySQL back-end is quite a heavy solution, if you get a moderate number of clients. You'd probably also rely on each client to periodically ping the server to let it know they are still alive.

Share this post

Link to post
Share on other sites
The idea is completely plausible. You can use winsock, but it does mean writing the HTTP request yourself. You'd need something like:
//open connection to web server

write("GET /registerserver.php?ip= HTTP/1.1\r\nHost: myhost.com\r\n\r\n", ...);

Then in the PHP you have something like

$ip = $_GET["ip"];
$port = $_GET["port"];

//add it to the database


This is of course, completely unsecure, but it's a reasonable start.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!