Should be buf.writeInt32LE/buf.writeInt32BE. Docs for Buffer: http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_writeint32le_value_offset_noassert
On Fri, Sep 7, 2012 at 6:20 PM, Neha Jatav <[email protected]> wrote: > Hi Ben, > > Thanks for the quick response. I am getting the following error: > > buf.writeInt32(num, 0); > ^ > TypeError: Object the e has no method 'writeInt32' > > -Neha > > On Fri, Sep 7, 2012 at 6:07 PM, Ben Noordhuis <[email protected]> wrote: > >> On Fri, Sep 7, 2012 at 10:05 AM, Neha <[email protected]> wrote: >> > Is there an equivalent of java command writeShort() & writeByte() in >> net.js? >> > Can I write bytes and short instead of simply writing a string to a >> socket? >> >> var buf = new Buffer(6); >> buf.writeInt16(42, 0); >> buf.writeInt32(1337, 4); >> sock.write(buf); >> >> > Also, can I write a JSON object - an equivalent to the following in >> python:- >> > >> > json_message=json.dumps(message) >> > s.send(json_message) >> >> sock.write(JSON.stringify(message))? >> >> -- >> 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 >> > > -- > 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 > -- 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
