开发者

Difference between NetworkToHostOrder and HostToNetworkOrder?

开发者 https://www.devze.com 2023-04-05 08:39 出处:网络
It seems that with any given input both of these functions return the same value. Does that mean that my computer is using big-endian (Win7)? Because I know NetworkOrder is in big-endian so c开发者_高

It seems that with any given input both of these functions return the same value.

Does that mean that my computer is using big-endian (Win7)? Because I know NetworkOrder is in big-endian so c开发者_高级运维onverting between the two should do nothing, then?

I am a bit confused on when I have to use these functions. I am trying to write a simple client-server program and am currently just familiarizing myself with what MSDN has to say about the NetworkStream, IPAdress, and TcpClient classes.

When would I need to use these functions, if at all? When sending byte arrays to the server and back would I need to call these functions on the individual bytes before sending them off? I'd imagine not.. what about if I prepend the data with a length integer. Would I need to call HostToNetworkOrder on that?


Both functions do the exact same conversion; there's two functions so that your code will be more readable and the intention will stand out better.

Your windows system is running on an Inten (or AMD) processor and it's the processor that sets the word format... these are little endian machines.

0

精彩评论

暂无评论...
验证码 换一张
取 消