• Home
  • Tutorials
  • Downloads
  • Games
  • Articles
  • Contact

Data Management

Poor data management can effectively cripple your game. If you want more than 5 players online at once, you'll need to understand the concept of efficient data management.


To explain simply, you should know that your internet connection runs at a certain speed. It might take a few minutes to download a music track, or it might take a few seconds, based on the speed of your connection.

When you host your server, you need to understand that only so much data can be downloaded and uploaded at any given point, again based on the speed of the server's internet connection.

Whenever your clients send data packets to the server, the server must download them. Whenever your server sends data packets to clients, it must upload them. If your server is trying to download or upload too much data at a time, the packets will begin to build up and not be processed immediately.

To make sure that your server is able to process packets quickly, there are some common practices worth following.

Do not send lots of packets
Every packet in itself is 40 bytes, plus any additional content you write. This space is taken up due to the inclusion of important details in the header of a packet, such as the IP address it is traveling to and which port is being used.

Only send packets when they are necessary
There is no need to tell a client in a different zone that another client started dancing. Only send packets to the clients that need them, and only send relevant data.

Use the appropriate data type based on the size of what you want to send
There are a variety of data types which you can use to send messages. Each of the following data types take up different amounts of space within a packet, and you want to use the most efficient data type that is appropriate for what you are sending.
Data Types
Whenever you write contents to a packet, you can define it's data type. The size of a data type is based on the potential values that it can be used to represent.

A byte is a value between 0 and 255 inclusive (1 byte of data).
A short is a value between -32768 and 32767 inclusive (2 bytes of data).
An int is a value between -2147483648 and 2147483647 inclusive (4 bytes of data).
A string is a group of characters (1 byte of data plus 1 byte for each character).

There are a few more data types, but for the sake of simplicity we'll make use of these few for now.

That covers the basics of data management. The relevance of this information will become more obvious in later articles and examples.

Finished!
With the theoretical knowledge from this tutorial, you should be able to start the networking application tutorial!
Picture
Picture

How To Make An MMORPG © 2010-2012
Copyright | Privacy Policy