Not sure what board I should post this in. But I guess it's more of a showroom topic than support.
This idea was floating in my head for a while since I began using sockets a few years ago. And I'd like to hear your thoughts on this.
Probably the first thing you notice when you decide to learn how to send shit through the internet is that it
MUST be in the form of a string. Many people find this highly frustrating because the majority of server's data (including VCMP) consists of numbers. Which means you're forced to find creative ways import them into strings.
But this is not what I'm addressing. The second thing you realize is that when you send data, every single integer in your messages must be turned into a byte. Which is completely different when you move the numerical data trough a computer. Because it allows you to store far larger numbers than 0-9 to a single byte.
Now what's a byte? A byte is a memory unit that consists of 8 bits. Each bit can have two different states - true & false.
Which means a byte can have 256 different combinations. 256 different symbols you can store in a single byte.
Symbols that form the ASCII standard:
That means if you assign a predetermined numerical value for each symbol you can hold 256 different numerical values (Probably 0-255).
By now you probably got the point.
How do you use this method?Let's say we a have a message that a server wants to send to it's client.
And it was "169" - This message would take 3 bytes of data. Now if you made an algorithm for converting it...
It could be turned to "☺" and wolah! You just saved 3x of space!
But what about values that go beyond 255? Like 256.No problem. In that case we just convert "25" and leave "6" be. At the end of the day we are guaranteed to save at least 2x of bandwidth.
What about more complex stuff?Let's say that the message contains "15499145" it could be converted to: "SAY" Got it?
I converted 154 to 'S', 99 to 'A' and 145 to 'Y'. So we turned a 8 byte message to 3 bytes.
What about text?This method can be used on text too! VCMP let's you chat with less than a 100 difirent symbols.
Which means you can shorten your text strings at least 2x.
But won't this make my server need more computer power? If you actually got to the point when you want to ask this, I have only one response:
Go kill yourself.Seriously? These aren't the late 80's and early 90's. I'm sure your server/client can handle constant string manipulation.
To finish the post I'd like to say that this seems like a very useful method for people that want to cut bandwidth for their applications.
It's flexible and it can be used for many different approaches and combinations.