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