Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2501
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: little-endian |
| Date | 2012-11-18 15:17 +1300 |
| Message-ID | <agquqgF2uveU2@mid.individual.net> (permalink) |
| References | (5 earlier) <87mwygpolg.fsf@informatimago.com> <k88hoj$fvl$1@news.albasani.net> <agqab0F2uveU1@mid.individual.net> <7otfa8pfb07sn1ao039nlfc9cr351h2vtr@4ax.com> <k892t5$p77$1@news.albasani.net> |
On 11/18/12 11:22, BGB wrote: > On 11/17/2012 2:48 PM, Robert Wessel wrote: >> On Sun, 18 Nov 2012 09:28:16 +1300, Ian Collins<ian-news@hotmail.com> >> wrote: >> >>> On 11/18/12 06:30, BGB wrote: >>>> >>>> typically, a person may develop and use functions like: >>>> ReadInt32BE >>>> and WriteInt64LE and similar, and use these for most of the encoding. >>> >>> Typically a programmer will use the utilities their platform provides. >>> > > typically a programmer will do whatever is most convenient at the moment. Which tends not to involve reinventing wheels! <snip> >>>> also, a big downside of using htonl and ntohl as a general mechanism is >>>> that it makes all of ones' libraries need to depend on winsock. >>> >>> That's silly on at least three counts: >>> >>> 1) the whole would doesn't revolve around windows. >>> >>> 2) those utility functions are usually implemented in-line (typically as >>> macros), so there isn't a library dependency. >>> >>> 3) if you are sending data over IP, you need the socket libraries one >>> way or another! >> > > you still have to include "winsock.h" or "sys/socket.h" (on Linux), and > all the relevant #ifdef's, ..., or similar, which means that they don't > really make sense except for code dealing with sockets. The headers take care of the relevant defines. > for most "general" file reader/writer code, it doesn't make sense to > have such dependencies. Unless you want to avoid wheel reinventing... >> Some more valid criticisms of the hton*/ntoh* functions are that they >> only support one byte order on the "network" side, support only a >> couple of sizes, and only support unsigned values. long long version are a simple extension. The signed or unsigned nature of the type isn't relevant for byte ordering. > and they only do direct value -> value mappings... Which is their purpose. > far more common I think is to implement file-readers more like: > int MyFile_ReadInt32LE(FILE *fd) The reason for using the common byte ordering functions is to avoid having to care about the ordering on the wire (or in a file). -- Ian Collins
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
little-endian bob <bob@coolfone.comze.com> - 2012-11-15 13:45 -0800
Re: little-endian JJ <jaejunks@glegooilma-swapit.com> - 2012-11-15 23:33 +0000
Re: little-endian bob <bob@coolfone.comze.com> - 2012-11-16 10:38 -0800
Re: little-endian "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-16 23:32 +0100
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-16 21:17 -0600
Re: little-endian "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-17 10:26 +0100
Re: little-endian "BartC" <bc@freeuk.com> - 2012-11-17 11:38 +0000
Re: little-endian "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-17 13:56 +0100
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-17 11:58 -0600
Re: little-endian Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-11-17 19:35 +0000
Re: little-endian "BartC" <bc@freeuk.com> - 2012-11-17 19:50 +0000
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-17 11:30 -0600
Re: little-endian Ian Collins <ian-news@hotmail.com> - 2012-11-18 09:28 +1300
Re: little-endian Robert Wessel <robertwessel2@yahoo.com> - 2012-11-17 14:48 -0600
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-17 16:22 -0600
Re: little-endian Ian Collins <ian-news@hotmail.com> - 2012-11-18 15:17 +1300
Re: little-endian "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-11-18 09:13 +0100
Re: little-endian Ian Collins <ian-news@hotmail.com> - 2012-11-18 21:33 +1300
Re: little-endian "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-11-18 10:15 +0100
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-18 03:03 -0600
Re: little-endian "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-11-18 10:29 +0100
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-18 12:50 -0600
Re: little-endian Robin Vowels <robin.vowels@gmail.com> - 2012-11-22 04:49 -0800
Re: little-endian Jongware <jongware@no-spam.plz> - 2012-11-23 15:22 +0100
Re: little-endian pacman@kosh.dhis.org (Alan Curry) - 2012-11-25 19:39 +0000
Re: little-endian Jongware <jongware@no-spam.plz> - 2012-11-26 12:01 +0100
Re: little-endian "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-11-26 14:02 +0100
Re: little-endian Jongware <jongware@no-spam.plz> - 2012-11-26 15:34 +0100
Re: little-endian "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-11-26 17:03 +0100
Re: little-endian Robert Wessel <robertwessel2@yahoo.com> - 2012-11-26 17:44 -0600
Re: little-endian Robin Vowels <robin.vowels@gmail.com> - 2012-11-28 23:43 -0800
Re: little-endian Robert Wessel <robertwessel2@yahoo.com> - 2012-11-29 22:46 -0600
Re: little-endian BGB <cr88192@hotmail.com> - 2012-11-26 08:30 -0600
Re: little-endian Robin Vowels <robin.vowels@gmail.com> - 2012-11-28 23:45 -0800
csiph-web