This preview shows page 1. Sign up to view the full content.
Unformatted text preview: separated from the other bytes by a period. For example, 184.108.40.206 is the dotted-decimal representation of the address 0x8002c2f2. You can use the Linux HOSTNAME command to determine the dotted-decimal address of your own host:
linux> hostname -i 220.127.116.11 Internet programs convert back and forth between IP addresses and dotted-decimal strings using the inet aton and inet ntoa functions:
#include <arpa/inet.h> int inet aton(const char *cp, struct in addr *inp);
returns: 1 if OK, 0 on error char *inet ntoa(struct in addr in);
returns: pointer to a dotted-decimal string The inet aton function converts a dotted-decimal string (cp) to an IP address in network byte order (inp). Similarly, the inet ntoa function converts an IP address in network byte order to its corresponding dotted-decimal string. Notice that a call to inet aton passes a pointer to a structure, while a call to inet ntoa passes the structure itself.
Aside: What do ntoa and aton mean? The "n" denotes network representation. The "a" denotes application representat...
View Full Document
- Spring '10
- The American