Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (g - h) gethostbyname_r(3)
• If you are using the Light Weight Resolver library, you must also compile your applica-
tion using the #define LWRES macro or an equivalent compiler command option.
• If you are using a 64-bit library, you must also compile your application using the |
-Wlp64 compiler command option.
If you are using the Standard POSIX Threads library, you must:
• Include the spthread.h header file
• Link your application to:
/G/system/sysnn/zsptsrl (G-series)
or
/G/system/zdllnnn/zsptdll (H-series or J-series)
• Compile your application using the #define _SPT_MODEL_ macro or an equivalent
compiler command option
If you are using this function in a threaded or 64-bit application in a system running H06.21 or a |
later H-series RVU or J06.10 or a later J-series RVU, you might need to include additional files |
or use additional macros. For more information about threaded and 64-bit applications in the |
OSS environment, see the Open System Services Programmer’s Guide.
In a threaded environment, the behavior of the application is undetermined if more than one
thread in application is calling different sequences of the sethostent( ), gethostent( ),
gethostent_r( ), gethostbyaddr( ), gethostbyaddr_r( ), gethostbyname( ), gethostbyname_r( ),
or endhostent( ) functions.
RETURN VALUES
Upon successful completion, gethostbyname_r( ) returns a pointer to a hostent structure if the
entry was found, and a null pointer if the entry was not found. If the call to gethostbyname_r( )
fails, a null pointer is returned. If an entry is found, the pointer returned by this function points to
the same hostent structure as pointed to by the host parameter.
The structure of type hostent is defined in the netdb.h header file as:
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
};
The fields of this structure are:
h_name Points to the official name of the host. This name is also known as the canonical
name of the host.
h_aliases Points to an array of pointers to alternate names for the host.
h_addrtype The type of address being returned. Its value is always AF_INET, which indi-
cates that this is an Internet address.
h_length The length, in bytes, of each entry pointed to by h_addr_list. Typically,
h_length is four bytes
527187-017 Hewlett-Packard Company 3−63