![]() Chapter Contents |
![]() Previous |
![]() Next |
| hstrerror |
| Portability: | SASC |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| EXAMPLE | |
| RELATED FUNCTIONS |
| SYNOPSIS |
#include <netdb.h> char *hstrerror( int errnum );
| DESCRIPTION |
hstrerror maps the h_error number in errnum to
an error message string.
| RETURN VALUE |
hstrerror returns a pointer
to a message describing the h_error number.
| EXAMPLE |
#include <sys/types.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
main(int argc, char *argv[])
{
struct hostent *hp;
struct in_addr ip_addr;
/* Verify a "hostname" parameter was supplied */
if (argc <1 || *argv[1] == '\0')
exit(EXIT_FAILURE);
/* call gethostbyname() with a host name. */
/* gethostbyname() returns a pointer */
/* to a hostent struct or NULL. */
hp = gethostbyname(argv[1]);
if (!hp)
{
printf("gethostbyname failed. \"%s\"\n", hstrerror(h_errno) );
printf("%s was not resolved\n", argv[1]);
exit(EXIT_FAILURE);
}
}
| RELATED FUNCTIONS |
herror, perror,
strerror
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.