Skip to main content
GameDev.net gamedev.net
🔒 Locked

MMORPG games and databases

Started by TheGecko Aug 27, 2006 at 3:19 AM 3 replies 1k views
Original Post
TheGecko
TheGecko
Hey all. Out of curiousity, how do MMORPG games communicate with their databases? I don't think they do it via a direct connection to the database server on a certain port :p That would mean anyone would be able to connect (given a username and password) and send SQL statements and modify the database. I thought about maybe a service that is running on a server between the client and the database server, but I am unsure how the client would send SQL statements to the server and how the server would send back the recordsets. Anyone understand what I'm getting at? I'm trying to make a small game that needs a connection to an remote database server but I am unsure how t go about doing it. Any help or links would be much appreciated!
DaBono
DaBono
Quote:
Original post by TheGecko
Out of curiousity, how do MMORPG games communicate with their databases? I don't think they do it via a direct connection to the database server on a certain port :p That would mean anyone would be able to connect (given a username and password) and send SQL statements and modify the database.

Actually, I think they do use a connection on a certain port.
However, that database server would be located on a subnet of the network, protected by a firewall, so that no other IP than that of the game servers is allowed to connect.

EDIT: Reading your post again; note that your MMORPG game client will never communicate with the database directly. As you said, that would circumvent validation of your actions. Instead, you communicate with a game server, that checks if what you're doing is allowed. If it is, it will change whatever data needed on the database server.
darkbard
darkbard
A MMOG has two important entities: the client and the server. Both are applications that communicate trought the network using custom protocols to send messages: the client runs on player' computers and the server on remote machines. When the server needs to store some data, it saves it usually into a database: the comunication between the database server and the server itself is done locallyì. The client cannot (and DO NOT HAVE TO) talk directly to the database server. If it does an operation that needs to store some informations, it sends a message to the server using the custom protocol and the server, if the operation is permitted, sends the right queries to the local database server.
TheGecko
TheGecko
Quote:
it sends a message to the server using the custom protocol and the server, if the operation is permitted, sends the right queries to the local database server.


That's exactly the info I'm looking for. Now, what does "custom protocol" mean? This is what I'm trying to figure out. Technically, how does the process work?

Say in my game client I put in an instruction to build a skyscraper at location (100,20,200) in the game world. How does the game client send this info to the game server and then the game server saves this data in the database and return "skyscraper001" back to the client?

I guess what I'm trying to figure out is this "custom protocol" thing as that seems to be the key.
darkbard
darkbard
Quote:
Original post by TheGecko
That's exactly the info I'm looking for. Now, what does "custom protocol" mean? This is what I'm trying to figure out. Technically, how does the process work?


To comunicate the server and the client needs to understand each other. A protocol is nothing more that a list of rules used to describe the way the server and client comunicate trought the network.
Let's assume you established a TCP connection between the two entities and then you want to send a message from one entity to the other. This message must be formatted using the protocol rules so both the client and the server can understand it. In most cases the message is nothing more than a structure containing needed informations (such as message id, message size and some custom data based on the message type) that is written on the comunication stream.

Quote:
Original post by TheGecko
Say in my game client I put in an instruction to build a skyscraper at location (100,20,200) in the game world. How does the game client send this info to the game server and then the game server saves this data in the database and return "skyscraper001" back to the client?


First of all you have to choose a protocol: let's assume you choosed that messages between entities are identified by an id and contains some custom data that will be interpreted differently based on the message type. Message ids have to be understood correctly by both the server and the client.
When the client needs to tell the server it have to build a skyscraper al location X, it simply create a message composed by the right id and the data needed to the server so it will behave correctly. The server than recives the message and, based on its id, interprets it doing the operation requested (creating a new skyscraper into the database). Then sends back to the client a new message with the id of the object created.

This might not be the right way you should implement comunication between your clients and your server, but it should give you and idea of how to do that.

For a better explanation for what a protocol is, look here.

Knowing what a protocol is and how it should be implemented is required if you'd like to develop multiplayer games.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.