🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2450

Re: Little/Big Endian

#2450
From: Remy Lebeau (TeamB)
Date: Wed, 12 Apr 2006 16:28
20 lines
1717 bytes
<Endian> wrote in message news:443d1ceb$1@newsgroups.borland.com...

> Becasue Pentium processor in PC and ARM processor in the
> embedded unit use different endians (litte & big endians) the byte
> orders in the transmitted and received structures will be different.
>
> How to solve this little/big endian problem?

It is common practice to always transmit data over the network in 'network
byte order' only.  That way, the format of the data is standardized across
platforms.  On each endpoint of the connection, the software running on that
machine can convert the data to/from its local 'host byte order' as needed.

Look at the socket API htons() and htonl() functions for converting values
to 'network byte order', and ntohs() and ntohl() for converting them back to
'host byte order'.


Gambit
Technical Details
Message-ID: <443d2abf$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <443d1ceb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b7bbc0a1e538a2f9
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <443d1ceb$1@newsgroups.borland.com>
Subject: Re: Little/Big Endian
Date: Wed, 12 Apr 2006 09:28:52 -0700
Lines: 22
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <443d2abf$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1144859327 68.69.17.41 (12 Apr 2006 09:28:47 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail