I’m writing a simple I/O class in order to use at a multiplayer game. Actually everything is Ok, but I’m trying find a way to optimize it in both overall performance and packet sizes.
The class is here
Also, few days ago I found this class and saw that it works directly on the bits. Doing that would be better to improve my class?
Thanks and sorry for the poor english.
Edit:
I’m using TCP, and the packet layout is the header (single byte) followed by entropy data (String, Int16, Int32, Int64, byte and byte array).
The packet max size is 4kb.
That package cannot be optimized more if you cant reduce the size of any of the fields.
4kb data is roughly 32kbit/s which means that you can transmit a package to about 300 clients per second on a 10mbit/s connection. Are you saying that you need to handle more clients per second?
The best way to optimize your application is likely to use a buffer pool instead of creating a new buffer for each packet to send.
And as always: Don’t optimize until you really need it, since you’ll likely have to sacrifice readability.