Beginning network data transfer questions
Hello all I have recently setup my client and server apps to start and initialize winsock 2. Im using TCP since its a turn based game so data isn't time critical. Anyway, I wanted to know what do I do now in terms of starting communication between the two. 1. What is the first batch of information the client sends to the server ? (not game specific, just like to know what any game would send) 2. How would I be able to tell if the client is the true game client and not some other application trying to connect and what should I do if its the latter? 3. After the first batch of information, how should I 'group' my data (in the client) for sending? Thanks
Quote:
1. What is the first batch of information the client sends to the server ? (not game specific, just like to know what any game would send)
I would send stuff like the version of the client being used, a set of credentials to prove that the client is valid, and information about the player (username, team, current rating, whatever)
Quote:
2. How would I be able to tell if the client is the true game client and not some other application trying to connect and what should I do if its the latter?
You can go as in-depth as you wish on this. One simply way would be for the application to generate and send a unique key. This key is then checked to be valid by the server (because both would use the same algorithm). This has the advantage of simplicity and speed.. unfortunately, a look at the code (or at a list of the sent keys) could reveal an algorithm to replicate the key. This should be sufficient for most games though. If not, you could look up identification algorithms (Schnorr will do it if you're a masochist and really need that level of protection)
Quote:
3. After the first batch of information, how should I 'group' my data (in the client) for sending?
I would have two parts on each message.. the first is the header that describes the type of data following (unit position, unit command, technology upgrade, etc.). This tells the server how much data and the format of the data to expect in the second part. Data could be sent simply stating the position and state of the units (moving, standing, firing).. or the server could handle everything and the client would simple send the orders that the player gives to the server.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
For me:
1: Actually, I have the server send the first bit of information. Included is a command length, the size in bytes of the uid being used, the console's uid, and the uid assigned to the new client.
2: I don't try. If the client sends invalid commands, the commands get dumped. If a client tries to connect in the middle of a game, dumped. If another player sees a client connect that won't click ready for the game, they can get admin and kick the broken client.
3: I actually serialize everything to human readable strings/commands and send those. Inefficient, but easy [easier anyways] to debug. An added benefit is that save/load game uses the same serialization.
1: Actually, I have the server send the first bit of information. Included is a command length, the size in bytes of the uid being used, the console's uid, and the uid assigned to the new client.
2: I don't try. If the client sends invalid commands, the commands get dumped. If a client tries to connect in the middle of a game, dumped. If another player sees a client connect that won't click ready for the game, they can get admin and kick the broken client.
3: I actually serialize everything to human readable strings/commands and send those. Inefficient, but easy [easier anyways] to debug. An added benefit is that save/load game uses the same serialization.
Quote:
. What is the first batch of information the client sends to the server ? (not game specific, just like to know what any game would send)
My client sends up a connect request which consists of a packet header, and a very specific message the server is looking for. Upon receiving this, the server will attempt to add the player to the game and return a very specific message containing the result of the action.
Quote:
2. How would I be able to tell if the client is the true game client and not some other application trying to connect and what should I do if its the latter?
I sort of took the path of both posters before me. Upon connection I generate a random "challenge id" and send it up to the host along with the connection accepted message. The client will hold onto this value, and on the next ack. will send it back to the server. Upon seeing this, the server will know this client and go ahead and add them to the game.
As for during gameplay itself (since I'm using UDP I have to worry about this), my message execution is looking for very specific messages types and lengths, all of which are not readable right out the gate even by a sniffer program. My messages can be traced if the viewer figures out my algorithm as well as use of bitwise operators, but this makes it a little more difficult to get through ^_^.
Quote:
3. After the first batch of information, how should I 'group' my data (in the client) for sending?
I agree with Falkone, that being the first x bits of the message being a header, followed by x bit of data. Both my client and server will tack on a 12 bits of data, then any reliable data which needs to be sent, followed by any unreliable data if there is space available.
Hope this answers your question ^_^,
Permafried-
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement