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

Benoît Minisini gambas at ...1...
Thu Apr 7 18:20:30 CEST 2011


> > 
> > Because sockets are big endian, not little endian as the CPU. I think you
> > have to use READ to decode the messages as soon as you receive them.
> > 
> > If you want to process them later, you can use a Variant[] to store the
> > decoded data instead of a String storing the undecoded data.
> 
> I don't know what to say. The endianness should automatically be
> decoded; I thought was the whole point of removing the Mk*$() functions.
> 
> A transaction can be something like, "Okay, good job" or an entire clip
> of the world terrain in dozens of blocks. It can't just be stored in an
> array as a Variant.
> 
> What do the string values mean? Are they reversed and/or inverted bits?
> If I can flip the bits I can get back to work.

When you write the data to the socket, all data are converted from the CPU 
endianness (little endian for Intel/AMD) to the network endianness (big endian 
by definition).

When you read the data from the socket, the data must be converted back from 
big endian to little endian, and it is done automatically by READ.

But if you read everything inside a string, that is not done, because string 
are bytes, and so do not have endianness.

Do you have an example of code that takes the socket data from a big message 
like you described and decode it?

We will find a solution!

-- 
Benoît Minisini




More information about the User mailing list