Skip to main content
gamedev.net
🔒 Locked

Binary packets

Started by Little Coding Fox Jan 8, 2007 at 2:39 PM 2 replies 1k views
Original Post
Little Coding Fox
Little Coding Fox
Hello everyone! I'm writing a TCP Client/Server and i'd like to know what exactly Binary Packets are and how they work, and also how can i add support to Binary Packets to my TCP Client/Server to save bandwidth (at least i think Binary Packets save bandwidth 'cos they're not text). Thank you all for your help, and have a nice day!
Anon Mike
Anon Mike
Your statement is a little ambiguous but I'm guessing this is an instance of question 15 in the forum FAQ
-Mike
Sirisian
Sirisian
It's a little more complex than the FAQ makes it. Sending a struct isn't the best idea.

http://www.gpwiki.org/index.php/Binary_Packet
http://gpwiki.org/index.php/Optimizing_Your_Online_Game_Bandwidth

Both those tutorials will help you. Binary packets are very convenient and will save you a lot of time. Make functions in your game objects to serialize certain packet data. Using something like the below code is acceptable:
GameObjectArray[5].serializePosition(&packet);

Read over those two articles first. The first one is mine and I've only made one game. The bottom one is written by the creator of VBgore.
hplus0603
hplus0603
Quote:
Sending a struct isn't the best idea.


There are many popular games that "send structs" and work very well. It's a great way to get started. You only need to improve on that method when and if you determine you can't create an efficient protocol on top of structs.

And, when you improve, traditional stream serialization may or may not be the right direction to go in. Other approaches, such as state-ful compression or arithmetic coding, may give you a better overall improvement.

I agree that binary serialization is often useful, especially when you can combine it with knowledge of needed range and precision of different data elements, but it's not a given that it's always the right fit for any specific problem.
enum Bool { True, False, FileNotFound };

Topic Locked

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

Sign in to reply to this topic.