|
Internet Programming Basics
An Introduction with Examples in C |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
htons() for "short" values (i.e., of type
uint16_t)htonl() for "long" values (i.e., of type
uint32_t)ntohs() for "short" values (i.e., of type
uint16_t)ntohl() for "long" values (i.e., of type
uint32_t)
const char *inet_ntop(int domain, const void *net, char *pres, size_t length)
domain
|
AF_INET or AF_INET6 |
net
|
The address to convert |
pres
|
The human-readable version |
length
|
The length of the human-readable version |
| Return | Pointer to dest on success, NULL on error |
Note: This function just converts from one format to another.
int inet_pton(int domain, const char *pres, void *net)
domain
|
AF_INET or AF_INET6 |
pres
|
The human-readable version |
net
|
The address in binary format |
| Return | 1 on success; 0 on error |
Note: This function just converts from one format to another.
int getifaddrs(struct ifaddrs **first)
first
|
A pointer to the first address in a linked structure of addresses |
| Return | 0 on success; -1 on error |
Note: This function reads the information from the file system.
int gethostname(char *name, size_t length)
name
|
The name of the local host |
length
|
The maximum length of a host name |
| Return | 0 on success; -1 on error |
Note: This function reads the information from the file system.