Useful Functions

Function/Include Description
uint32_t htonl(unint32_t hostlong)
#include <netinet/in.h>
Converts a 32-bit value from a host byte ordered value to a network byte ordered value.
uint32_t ntohl(uint32_t netlong)
#include <netinet/in.h>
Converts a 32-bit value from a network byte ordered value to a host byte ordered value.
uint16_t htons(uint16_t hostshort)
#include <netinet/in.h>
Converts a 16-bit value from a host byte ordered value to a network byte ordered value.
uint16_t ntohs(uint16_t netshort)
#include <netinet/in.h>
Converts a 16-bit value from a network byte ordered value to a host byte ordered value.
char *inet_ntoa(const struct in_addr in)
#include <arpa/inet.h>
Converts a network byte ordered value to a dotted-decimal string.
in_addr_t inet_addr(const char *cp)
#include <arpa/inet.h>
Converts a dotted-decimal string to a network byte ordered value.

Return to 594 lab home page
created by: Chad Bauer, Bug-fixed by Sam Reynolds