Hi,

you was right, and the answer was on the same documentation i linked. not 
calling to setEncoding will return to me a buffer with the binary data that 
i can handle :D

the only thing, that those bytes are not 0's but it prints me 128 0 7 2 but 
anyway, i'll keep playing with this, seeing how to parse correctly the 
binary data, at least i know that is possible :)

many thanks to all for your help, i'll make this code open source as soon 
is working, so anyone can use it if is needed :)

Regards,
Shadow.

El jueves, 9 de agosto de 2012 19:35:37 UTC-3, Eric S escribió:
>
>
>
> On Thursday, August 9, 2012 2:02:47 PM UTC-7, david rene comba lareu wrote:
>>
>>
>>
>> now, the linked library do all this, but get broken at the point of 
>> checking the 4 zero's. it uses the Net module to create a server, and 
>> listen on connection event. using the socket object provided by the event, 
>> set the encoding to "binary" (this type of encoding doesn't exist as far i 
>> see in the documentation
>> http://nodejs.org/api/stream.html#stream_stream_setencoding_encoding ) 
>> and then try to check for the four zero's
>>
>
> I'm not an expert yet, but I may have been following Node development long 
> enough to explain this.  As I understand it, "binary" encoding was how node 
> handled binary data originally, but this was replaced by buffers at some 
> point because it wasn't handling things in a smooth manner.  A buffer is 
> basically an array of octets with no character fiddling (in order to 
> transparently handle binary data).
>
> Now, the documentation you linked to states that if stream.setencoding() 
> isn't called, then the data event emits a buffer, which I think is exactly 
> what you want.  Assuming that you've got a buffer that just happens to 
> start at the start of the packet (which may not be a safe assumption, just 
> using that as an example), buffer[0] would be the version number, 
> buffer[1]-buffer[4] would be the timestamp, and buffer[5]-buffer[8] would 
> be your zeros.
>
>

-- 
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

Reply via email to