Chapter Contents

Previous

Next
gethostbyaddr

gethostbyaddr



Gets Host Information by Address

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
PORTABILITY
IMPLEMENTATION
RELATED FUNCTIONS


SYNOPSIS

#include <netdb.h>

struct hostent *gethostbyaddr(const char *addr, int len, int type);


DESCRIPTION

Given the address of a host, gethostbyaddr returns a hostent structure containing the host's name and other information. This structure is typically used to obtain the name of the host from the h_name field. Refer to <netdb.h> for details on the hostent structure. For TCP/IP, addr should point to struct in_addr or an unsigned long integer in network byte order, len is normally the sizeof(struct in_addr) , and type should be AF_INET .

Host information is found either through the resolver or in your system's equivalent of the /etc/hosts file. Refer to gethostbyname and Resolver Configuration for a description of the logic that determines how the host address is found.


RETURN VALUE

If gethostbyaddr succeeds, it returns a host address. A null pointer indicates the network address was not found in the network file.


CAUTION

The value that gethostbyaddr returns points to a static structure within the library. You must copy the information from this structure before you make further gethostbyname , gethostbyaddr , or gethostent calls.


PORTABILITY

The logic that determines whether to use the host file or the resolver is not uniform across environments. At the source code level, however, gethostbyaddr is portable to other environments, including most UNIX systems, that implement BSD sockets.


IMPLEMENTATION

The SAS/C implementation of gethostbyaddr is a combination of the host file and resolver versions of the BSD UNIX Socket Library gethostbyaddr function.


RELATED FUNCTIONS

gethostbyname , gethostent , sethostent


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.