z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


GETHOSTBYADDR

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

Use the GETHOSTBYADDR command to resolve an IPv4 address to a host name.

This command uses a domain name system (DNS) server. If the IP address is not resolved by the DNS server, then the resolver searches the local hosts tables. For information about the local host tables, see z/OS Communications Server: IP Configuration Guide.

Restriction: This command does not support IPv6 addresses.
Tips:

Format

Read syntax diagramSkip visual syntax diagram
>>-SOCKET--(--"GETHOSTBYADDR"--,--ipaddress--+-----------+--)--><
                                             '-,--domain-'      

Parameters

ipaddress
The IP address of the remote host.
domain
The network domain to which the IP address belongs. The only supported domain is AF_INET or 2.

Returned value

This command returns a string that contains the return code and the host name, for example, 0 ABCD.RALEIGH.IBM.COM. The return code can be 0 or the REXX API error number. The return code 0 indicates that the requested socket command was completed successfully.

See Socket call error return codes for additional information about the numeric error codes that are returned by this command.

The following REXX socket API error numbers can be returned:
  • 2001 EINVALIDRXSOCKETCALL
  • 2005 ESUBTASKNOTACTIVE
  • 2017 EIPADDRNOTFOUND

LE C/C++ equivalent

struct hostent *gethostbyaddr(char *address, 
       int address_len, int domain);

Code example

Figure 1. GETHOSTBYADDR command example
/* REXX EZARXR08 */
/*
 * This sample demonstrates the use of the GETHOSTBYADDR
 * socket command.
 */
src = socket("INITIALIZE","MYSET01");
if perror(src,"INITIALIZE") = 0 then do
   Say socket("GETHOSTBYADDR","128.123.222.1");
end;

src = socket("TERMINATE","MYSET01");
src = perror(src,"TERMINATE");
exit 0;

/* This routine returns -1 if the first word if arg 1 is not zero */
perror: if word(arg(1),1) = 0 then return 0; else
    Say arg(2) "Error : "arg(1);
    return -1;

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014