gethostbyaddr

Searches the host database sequentially from the beginning of the database for a host record with a given address.

Format

#include  <netdb.h>

struct hostent *gethostbyaddr  (char *addr, int
                               len, int type);
Routine Variants This socket routine has a variant named __bsd44_gethostbyaddr. Enabled by defining _SOCKADDR_LEN, this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.

Arguments

addr
A pointer to a series of bytes in network order specifying the address of the host sought. This argument does not point to an ASCII string.
len
The number of bytes in the address pointed to by the addr argument.
type
The type of address format being sought. Currently, only AF_ INET (defined in <socket.h>) is supported.)

Description

This routine finds the first host record in the host database with the given address.

The gethostbyaddr routine uses a common static area for its return values. This means that subsequent calls this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.

Return Values
NULL  Indicates an error. 
A pointer to an object having the hostent structure. See <netdb.h> for a description of the hostent structure.

Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See sections A.5 and A.6.)  


Previous Page | Next Page | Table of Contents | Index