Re: Data transfer(little/big endian)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Phil Frisbie, Jr. (phil_at_hawksoft.com)
Date: 05/11/04

  • Next message: Scott: "Get RPC to listen to more than 1 port?"
    Date: Tue, 11 May 2004 12:03:43 -0700
    
    

    vipin wrote:

    > Hello,
    >
    > I am wondering when I would face big endian and little endian issues over
    > the network.
    >
    > I guess the issue is not with the network itself but in the host computers.

    That is correct.

    > let say the client machine is solaris and server is windows and I want to
    > pass an integer
    > across the network, I should run the ntohl and htonl at each connection
    > endpoints so as to get in the proper host order.

    That is one portable way to do it, however network byte order is big endian. If
    most of your computers are running Windows (on little endian Intel/AMD cpus),
    and you are sending a lot of data, then writing your own macros that use little
    endian order will result in fewer data conversions.

    > Is my understanding right or do I need to take care of some other thing too
    > on transfer of data?

    Floats need a little more care if you use a platform that does not support IEEE
    format floats. And watch out for multibyte unicode strings....

    > thank you
    > vipin

    -- 
    Phil Frisbie, Jr.
    Hawk Software
    http://www.hawksoft.com
    

  • Next message: Scott: "Get RPC to listen to more than 1 port?"

    Relevant Pages

    • Re: Socket C
      ... The "Hello" string was only to exemplify. ... my machine is little endian. ... network will be in network byte order. ... feasible to transmit data in native byte order; ...
      (comp.lang.c)
    • Re: Socket C
      ... my machine is little endian. ... network will be in network byte order. ... feasible to transmit data in native byte order; ... doesn't make sense char in big or little endian. ...
      (comp.lang.c)
    • Re: Socket C
      ... The "Hello" string was only to exemplify. ... my machine is little endian. ... Big/little endian doesn't affect chars. ... network will be in network byte order. ...
      (comp.lang.c)
    • Re: Miniport NIC controller descriptor definition
      ... Windows is always little endian. ... adapt their data structures (descriptors etc.) to little or big endian ... This is not an unusal thing for Windows network programmers as all the ...
      (microsoft.public.development.device.drivers)