Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by Endian
Wed, 12 Apr 2006 15:29
Little/Big Endian
Author: Endian
Date: Wed, 12 Apr 2006 15:29
Date: Wed, 12 Apr 2006 15:29
27 lines
1711 bytes
1711 bytes
Assume that we want to communicate (a) via RS232 and (b) via ethernet
between a PC and an ARM based embedded controller unit (and/or a PDA)
Assume that most of the communication consist of transmitting/receiving of
messages similar to the following structure. Also assume that both PC
application and ARM application use the same header files for the messages.
typedef struct {
short int A;
int B;
float C;
double D;
unsigned char E;
}MyStruct;
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?
How to make PC application send/receive structures to a ARM based embedded
unit (a) via RS232 and (b) via ethernet between without worrying about the
endians?
Regards.
Re: Little/Big Endian
Author: Remy Lebeau (TeamB)
Date: Wed, 12 Apr 2006 16:28
Date: Wed, 12 Apr 2006 16:28
20 lines
1717 bytes
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
Re: Little/Big Endian
Author: JF Jolin
Date: Wed, 12 Apr 2006 22:32
Date: Wed, 12 Apr 2006 22:32
15 lines
1215 bytes
1215 bytes
The following article is about Writing Endian Independent Code in C++ http://www.gamedev.net/reference/articles/article2091.asp 13 Apr 2006 01:29:47 +1000, <Endian> wrote: > How to solve this little/big endian problem? > > How to make PC application send/receive structures to a ARM based embedded unit > (a) via RS232 and (b) via ethernet between without worrying about the endians? > -- JF Jolin
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads