[Gambas-user] gb3 RC1: using structures to replace the loss of Mk$ functions

Doriano Blengino doriano.blengino at ...1909...
Fri Apr 8 22:14:45 CEST 2011


Il 08/04/2011 09:04, Kevin Fishburne ha scritto:
> On 04/08/2011 02:32 AM, Doriano Blengino wrote:
>    
>>
>> Endiannes refers to the order the bytes are kept in memory, when a
>> numerical multi-byte value is involved. Strictly speaking, strings are
>> not affected. For example, human beings are big endian: the number 10,
>> composed by two digits, is written with the weighter digit first. If
>> human beings were little endian, they wrote this number as "01".
>>
>> ...
>>      
>
> So if endianness generally describes the byte order, not the bit order,
> then either each value (two, four or eight bytes) is reversed or the
> entire string is reversed. Hopefully it's the former rather than the
> latter, as that would be easier to compensate for.
>
> While it would be slow, I could just write functions for flipping the
> byte order of characters in a string. That would work fine for the
> client but may impact performance server side. I'll do some
> experimenting tomorrow to see what I can come up with.
>
>    
Perhaps I got it - but this should be confirmed by Benoit, I think.

On the client side, you can receive a packet as a string. Then you can 
use a memory stream to read from the string, so the endianness is coped 
with by the stream object. It should work. But this is only on the 
client side, the server already uses a stream to send the data, right?

BTW, I think that it is not true that you can not use a Variant. A 
Variant can be a string, and string's sizes are limited only by the 
available memory. I think you use a string anyway, even when you receive 
tiles and other big objects. With respect to a true string, a Variant 
wastes a little amount of memory, which is neglectable especially when 
using big chunks of data. The problem is that I don't see how a variant 
could help you...

The trick with string + memory stream should work for you.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list