big/little endian issues

This is a discussion on big/little endian issues within the Networking/Device Communication forums, part of the General Programming Boards category; I was reading about unix network programming when i found about the big/little endian problem. Im working on PC(as we ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    2

    big/little endian issues

    I was reading about unix network programming when i found about the big/little endian problem. Im working on PC(as we know Intel-based processors are little-endian), and if i need to send multi-byte numbers over a network, i have to convert them to big-endian format. My question is this, in a certain way, affects the character strings too? if im going to transmit any string, do i have to convert it in some format in order to send it over a network?

    Thanks in advance

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    NAME
    htonl, htons, ntohl, ntohs − convert values between host and network
    byte order

    SYNOPSIS
    #include <netinet/in.h>

    uint32_t htonl(uint32_t hostlong);

    uint16_t htons(uint16_t hostshort);

    uint32_t ntohl(uint32_t netlong);

    uint16_t ntohs(uint16_t netshort);
    You should have these already
    Then it doesn't matter whether your machine is big or little
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Endian Question
    By carrotcake1029 in forum C Programming
    Replies: 8
    Last Post: 01-07-2009, 02:51 PM
  2. Big Endian Little Endian Complex- Converting Characters
    By bd02eagle in forum C Programming
    Replies: 3
    Last Post: 07-11-2006, 01:01 AM
  3. Big and little endian
    By Cactus_Hugger in forum C Programming
    Replies: 4
    Last Post: 10-12-2005, 07:07 PM
  4. Replies: 10
    Last Post: 06-26-2005, 11:27 AM
  5. fopen, fwrite, and endian issues
    By FireAndGlass in forum C Programming
    Replies: 7
    Last Post: 06-19-2004, 07:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21