Standard io the ansii c standard denes a set of input

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: uniform network byte order (which is a big-endian byte order) for any integer data item, such as an IP address, that is carried across the network in a packet header. Addresses in IP address structures are always stored in big-endian network byte order, even if the host byte order is little-endian. Unix provides the following functions for converting between network and host byte order. 12.3. THE GLOBAL IP INTERNET #include <netinet/in.h> unsigned long int htonl(unsigned long int hostlong); unsigned short int htons(unsigned short int hostshort); 613 both return: value in network byte order unsigned long int ntohl(unsigned long int netlong); unsigned short int ntohs(unsigned short int netshort); both return: value in host byte order The hotnl function converts a 32-bit integer from host byte to network byte order. The ntohl function converts a 32-bit integer from network byte order to host byte order. The htons and ntohs functions perform corresponding conversions for 16-bit integers. IP addresses are typically presented to humans in a form known as dotted-decimal notation, where each byte is represented by its decimal value and...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online