By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,016 Members | 1,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,016 IT Pros & Developers. It's quick & easy.

host to network

P: n/a
How can I do a host to network conversion (similar to htonl) in
JavaScript? i.e. convert to network byte order irrespective of whether
host is little or big endian.

TIA,
KK

Dec 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kelvin wrote:
How can I do a host to network conversion (similar to htonl) in
JavaScript? i.e. convert to network byte order irrespective of whether
host is little or big endian.
JavaScript (at least 1.x) does not have a byte data type so I am not
sure where you are dealing with bytes and endianness at all. In what
context/host are you using JavaScript?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 5 '06 #2

P: n/a

Martin Honnen wrote:
Kelvin wrote:
How can I do a host to network conversion (similar to htonl) in
JavaScript? i.e. convert to network byte order irrespective of whether
host is little or big endian.

JavaScript (at least 1.x) does not have a byte data type so I am not
sure where you are dealing with bytes and endianness at all. In what
context/host are you using JavaScript?

OK, let me try to make this clearer. In C htonl will convert an IP
address from host byte order to network byte order. On a big endian
processor it does nothing and on a little endian one it reverses the
order of the 4 bytes that make up the address. Is there a similar
function in JavaScript?

K

Dec 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.