summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
47f8243)
fails, to replicate the behavior of LocalName().
#include <limits.h> /* for _POSIX_HOST_NAME_MAX */
#include <string.h> /* for memset */
#include <stdio.h>
#include <limits.h> /* for _POSIX_HOST_NAME_MAX */
#include <string.h> /* for memset */
#include <stdio.h>
if ((status = getaddrinfo(hostname, NULL, &hints, &res)) == 0) {
printf ("%s\n", res->ai_canonname);
freeaddrinfo(res);
if ((status = getaddrinfo(hostname, NULL, &hints, &res)) == 0) {
printf ("%s\n", res->ai_canonname);
freeaddrinfo(res);
+ } else {
+ printf("%s\n", hostname);
+ } else {
+ fprintf(stderr, "gethostname() failed: %s\n", strerror(errno));