Different method of networking a Video Game

I posted this in Random because it isn’t really language oriented, it’s more of a general question and thought. Also, I tried to post this once but I don’t think it worked. Sorry if this appears twice.

EDIT: Geez this is a long post.

I came up with an idea for a card game to rely more on strategy than actual cards yesterday. While I’m not completely planning to ever even start or attempt the project it’s been making me think of the networking aspect. Validation would be required for user input so people couldn’t cheat. Meanwhile using certain methods could be messier than others, resulting in less flexible coding (on my part due to laziness). I’ve come up with 3 general ways to do it and I was wondering if anybody else had an opinion.

  1. If I was using Java (or another language I imagine) I could simply use Sockets and ServerSockets over a TCP connection and pass data back and forth from client to server. The server would validate the information and send a response/game update to the client (invalid), or clients (valid). Of course, having a lot of people would require more servers and the servers wouldn’t be able to share any data. A match would be on the same server the entire time. If that server fails, the match is lost because it was stored in memory. Ideally I would think to have this Server be run by me, or the company, so people couldn’t cheat. However, this would create a lot of overhead. I don’t know much about security, but since I’m not just using a web server I imagine my program would be rather vulnerable. I know nothing about protecting it.

  2. Using the Sockets and ServerSockets it would also be possible to just have one of the two clients act as a server (I think that’s how Warcraft III works). However, having any sort of ranked match up would be difficult. Somebody could take the time to mod their server to validate illegal actions resulting in an unfair game. Also, I would still have to protect the program from attacks, which I don’t know about.

  3. The other option would be to just use a WebServer and use PhP or other server-side language to update a database like MongoDB? to simply save the state of the game via JSON. That means requests could jump from server to server without losing game data. If a server fails the clients wouldn’t notice, except maybe a slightly longer response time. I haven’t had much experience with using php or other server-side languages. The only webserver I’ve ever messed with was TomCat in a class. I know Blizzard uses TomCat in their StarCraft II launcher because I got an error page once. Most web servers have security inside of them (At least I think so). This would keep me from really needing to worry about intruders.

I’ve been thinking about all of this and juggling it around. I don’t know if anybody here has ever worked with a company dealing with networking or a multiplayer game, but how would you go about it if you were told to do this? You’d need to validate input somehow to protect users from losing to hacked games, but how often would that actually happen? Running your own server using java (Sockets and ServerSockets) could result in a lot of dropped matches and angry clients if one crashes mid-match. I haven’t had as much experience with Webservers like TomCat. I don’t know if you can create objects with php or other server-side languages. I feel as if using php would be messy compared to using an organized Java program. I know different companies take care of these different ways, but how would you do it?