HighDots Forums  

host to network

Javascript JavaScript language (comp.lang.javascript)


Discuss host to network in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kelvin
 
Posts: n/a

Default host to network - 12-05-2006 , 09:41 AM






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


Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: host to network - 12-05-2006 , 12:10 PM






Kelvin wrote:
Quote:
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/


Reply With Quote
  #3  
Old   
Kelvin
 
Posts: n/a

Default Re: host to network - 12-13-2006 , 05:51 AM




Martin Honnen wrote:
Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.