I agree!
Just a bit more: TCP headers are big-endians and "payload" is dont-care as long 
as you know how to get them on the other side

Note: I wrote a tcp/ip for DOS. I needed a function to swap endianness (intel 
is little-endian)...


Fedor Indutny <[email protected]> escreveu:
>Hello!
>
>I think you are a bit confused about endians and buffer representation
>in console. When you type `myBuff` it prints bytes in the same order
>as they'll be sent on network or written to file.
>
>i.e. `<Buffer 36 02 00 00>` means that `buf[0] === 0x36` and `buf[1]
>=== 0x02`, which is exactly how Little Endian should be represented.
>The big endian representation of your number will be 00000236 which
>means that  `buf[2] === 0x02` and `buf[3] === 0x36`.
>
>Cheers,
>Fedor.
>
>On Thu, Feb 27, 2014 at 12:30 PM, jduncanator <[email protected]>
>wrote:
>> Correct me if I'm wrong but I think there is an issue with the way
>Buffer's
>> endianness works (or at least the "description" the methods have).
>>
>> Lets say I create a new buffer:
>>
>> var myBuff = new Buffer(4);
>>
>> And now I wish to write an integer to my buffer in little-endian
>which has
>> the least significant byte first:
>>
>> myBuff.writeUInt32LE(566, 0);
>>
>> Now then, one would expect that this method just wrote the integer
>'566' to
>> my buffer in little-endian, but something odd goes on:
>>
>>> myBuff
>> <Buffer 36 02 00 00>
>>
>> Hang on, thats not little-endian, thats big-endian. If I were to send
>this
>> over the network now, and the other end expects the buffer to contain
>a
>> integer in little-endian, they would be rudely interrupted with a
>big-endian
>> integer. You can even demonstrate this by entering that hex into the
>> interpreter:
>>
>>> 0x36020000
>> 906100736
>>
>> Am I confusing what the BE and LE mean in the `write` functions or is
>> something weird going on?
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google
>Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it,
>send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>-- 
>-- 
>Job Board: http://jobs.nodejs.org/
>Posting guidelines:
>https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>You received this message because you are subscribed to the Google
>Groups "nodejs" group.
>To post to this group, send email to [email protected]
>To unsubscribe from this group, send email to
>[email protected]
>For more options, visit this group at
>http://groups.google.com/group/nodejs?hl=en?hl=en
>
>--- 
>You received this message because you are subscribed to the Google
>Groups "nodejs" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to [email protected].
>For more options, visit https://groups.google.com/groups/opt_out.

-- 
E-mail enviado do meu celular usando Kaiten Mail. Por favor, desculpe minha 
brevidade.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to