Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #35670

Re: htons, htonl, ntohs, ntohl

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: htons, htonl, ntohs, ntohl
Date 2013-08-24 11:22 +1200
Message-ID <b7q95eFeg9dU2@mid.individual.net> (permalink)
References <kv7jr7$eig$1@dont-email.me> <1bob8o1k22.fsf@snowball.wb.pfeifferfamily.net> <kv886i$lr0$1@speranza.aioe.org> <1bbo4o14oy.fsf@snowball.wb.pfeifferfamily.net>

Show all headers | View raw


Joe Pfeiffer wrote:
> glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:
>>
>> Seems to me less of a problem than the host machine's idea of long.
>>
>> Except for some strange cases, short has been pretty consisitently
>> just 16 bits, but htonl() and ntohl(), were defined in terms of long.
>
> No, from the same man page:
>
>         uint32_t htonl(uint32_t hostlong);

Note the past tense!  The POSIX interfaces were updated post-C99, just 
in time for the increase in popularity of little-endian 64 bit 
platforms.  I guess newcomers will miss the significance of the names.

>> In some years passed, int was either 16 or 32 bits, and long
>> was 32 bits. When Alpha came out, with 64 bit long, as well as I
>> understand it, all the IP code failed to compile.
>
> Hopefully this resulted in the code being rewritten in terms of uint32_t
> instead of long.

Alpha predated C99.

-- 
Ian Collins

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

htons, htonl, ntohs, ntohl "James Harris" <james.harris.1@gmail.com> - 2013-08-23 13:17 +0100
  Re: htons, htonl, ntohs, ntohl Siri Cruise <chine.bleu@yahoo.com> - 2013-08-23 05:34 -0700
  Re: htons, htonl, ntohs, ntohl James Kuyper <jameskuyper@verizon.net> - 2013-08-23 08:44 -0400
    Re: htons, htonl, ntohs, ntohl Keith Thompson <kst-u@mib.org> - 2013-08-23 08:36 -0700
      Re: htons, htonl, ntohs, ntohl James Kuyper <jameskuyper@verizon.net> - 2013-08-23 12:27 -0400
  Re: htons, htonl, ntohs, ntohl Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2013-08-23 09:52 -0600
    Re: htons, htonl, ntohs, ntohl glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-08-23 18:04 +0000
      Re: htons, htonl, ntohs, ntohl Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2013-08-23 15:24 -0600
        Re: htons, htonl, ntohs, ntohl Ian Collins <ian-news@hotmail.com> - 2013-08-24 11:22 +1200
        Re: htons, htonl, ntohs, ntohl glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-08-26 01:55 +0000
          Re: htons, htonl, ntohs, ntohl James Kuyper <jameskuyper@verizon.net> - 2013-08-25 22:03 -0400
          Re: htons, htonl, ntohs, ntohl Richard Damon <Richard@Damon-Family.org> - 2013-08-25 22:03 -0400
          Re: htons, htonl, ntohs, ntohl Ian Collins <ian-news@hotmail.com> - 2013-08-26 14:10 +1200
    Re: htons, htonl, ntohs, ntohl "James Harris" <james.harris.1@gmail.com> - 2013-08-23 21:16 +0100
      Re: htons, htonl, ntohs, ntohl Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2013-08-25 13:54 -0600
    Re: htons, htonl, ntohs, ntohl christian.bau@cbau.wanadoo.co.uk - 2013-08-30 10:58 -0700
      Re: htons, htonl, ntohs, ntohl Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2013-08-30 12:37 -0600
        Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-31 17:03 +0000
          Re: htons, htonl, ntohs, ntohl glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2013-08-31 18:13 +0000
            Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-31 20:52 +0000
          Re: htons, htonl, ntohs, ntohl Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2013-08-31 14:08 -0600
  Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-27 13:54 +0000
    Re: htons, htonl, ntohs, ntohl Stephen Sprunk <stephen@sprunk.org> - 2013-08-27 10:53 -0500
      Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-27 22:00 +0000
        Re: htons, htonl, ntohs, ntohl "James Harris" <james.harris.1@gmail.com> - 2013-08-27 23:15 +0100
          Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-28 11:10 +0000
            Re: htons, htonl, ntohs, ntohl James Kuyper <jameskuyper@verizon.net> - 2013-08-28 07:20 -0400
              Re: htons, htonl, ntohs, ntohl "James Harris" <james.harris.1@gmail.com> - 2013-08-28 12:47 +0100
                Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-31 16:40 +0000
      Re: htons, htonl, ntohs, ntohl "James Harris" <james.harris.1@gmail.com> - 2013-08-27 23:36 +0100
        Re: htons, htonl, ntohs, ntohl James Kuyper <jameskuyper@verizon.net> - 2013-08-27 18:54 -0400
        Re: htons, htonl, ntohs, ntohl Stephen Sprunk <stephen@sprunk.org> - 2013-08-27 21:02 -0500
          Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-28 14:10 +0000
            Re: htons, htonl, ntohs, ntohl Stephen Sprunk <stephen@sprunk.org> - 2013-08-28 15:06 -0500
            Re: htons, htonl, ntohs, ntohl christian.bau@cbau.wanadoo.co.uk - 2013-08-30 10:42 -0700
              Re: htons, htonl, ntohs, ntohl Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-08-31 11:49 +0000

csiph-web