The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Migrating Oracle from Big Endian to Little Endian Platorm luft UNIX and Linux Applications 3 05-22-2008 03:47 AM
Little Endiean and Big Endian Nirmal Babu UNIX for Dummies Questions & Answers 3 04-07-2006 12:50 AM
Endian Conversion bigmike59270 UNIX for Advanced & Expert Users 1 04-16-2004 11:18 AM
Big and Little Endian S.P.Prasad High Level Programming 1 11-12-2002 07:57 AM
AIX endian again Shobhit UNIX for Advanced & Expert Users 3 03-22-2002 06:13 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-28-2002
Registered User
 

Join Date: Feb 2002
Posts: 14
Unhappy Endian issues in TCP/IP

Hello,
Can anybody tell me whether the little endian-big endian issues will affect porting from True64 to HP UNIX or TCP/IP will take care of that? If it affects what can be the solution.
Thank you,
Forum Sponsor
  #2  
Old 03-01-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Your question is very confusing. I don't know if you are trying to port software or write a TCP/IP program.

Endian-ness is decided by the hardware not the the software. If an OS wants to use integer arithmetic, it must go along with what the hardware designers did. A very few cpu's are, um, bi-endian, but most have a preference.

HP hardware is big-endian.

TCP/IP does not even assume that computers have 8 bit bytes, which is why it calls 8 bits an "octet". 32 bit and 16 bit quantities travel over the network in big endian form. But portable programs access them via macros defined in the include file arpa/inet.h. The macros are ntohl, ntohs, htonl, htons. They stand for stuff like "network to host short". With big endian computers, these macros are null. But you should still use them. That way your code works on other computers. Only the macros need to be rewritten.
  #3  
Old 03-01-2002
Registered User
 

Join Date: Feb 2002
Posts: 14
Thanks a Lot for the reply.
More clarifications from my side are as follows.
1)We are trying to port a fully developed software which does communication from external world via TCP/IP and X.25 protocols.The original code is on COmpaq(little-endian) and it is to be ported on HPUX(big endian).
2)When same code is running on both HP and COmpaq platform,will the macros __BIG_ENDIAN__ and __LITTLE_ENDIAN__ in file /usr/include/netinet/in.h be defined automatically or we have to define on compliation.
  #4  
Old 03-03-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
I have never heard of any macros like that and I don't see them in HP's include file.

Big Endian and Little Endian are two ways to distribute the 4 bytes of a 32 bit integer. At least one other scheme is in use. If big endian is 4321 and little endian is 1234, then the other scheme is 2143. It arose when a 16 bit big endian cpu with a 16 bit adder implemented 32 bit arithmetic in two stages. It needed to add the low order words first to get the carry for the second addition stage. And these are just the three schemes that I know exist. There are 21 other ways to distribute 4 bytes of a 32 bit integer. And even that assumes that we can all stay in agreement that the bytes themselves are big endian.

The macros that I mentioned will handle all of the possibilities. If you use them you should never have to worry about or even know the structure of a word on your computer.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0