BPX4GHN (gethostbyname) example

The following code returns a pointer to a HOSTENT structure, which contains the alias names and the internet addresses of a host whose domain name is specified as input. For the callable service, see gethostbyname (BPX1GHN, BPX4GHN) Get IP information for specified host domain names.

The HOSTENT structure has the following format:
  • h_name - The address of the host name returned by the service. The host name is a variable length field that is ended by x'00'.
  • h_aliases - The address of a list of addresses that point to the alias names returned by the service. The list is ended by the pointer x'00000000'. Each alias name is a variable length field that is ended by x'00'.
  • h_addrtype - The value 2, which signifies AF_INET.
  • h_length - The length of the host internet addresses pointed to by h_addr_list.
  • h-addr_list - The address of a list of addresses that point to the host internet addresses returned by this service. The list is ended by the pointer x'00000000'.
AMODE 31 callers use BPX1GHN (gethostbyname) example.
                                              
         MVC   HOST_NAME(8),=CL8'HOST1234'                              
         MVC   HOST_NAMELEN,=F'8'                                       
         SPACE ,                                                        
         CALL  BPX4GHN,              Get host by name                  +
               (HOST_NAME,           Input: Name of Host being queried +
               HOST_NAMELEN,         Input: Length of host name        +
               HOSTENT_PTR,          Output: 0 or -> HOSTENT structure +
               RETVAL,               Return code                       +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               MF=(E,PLIST)          ----------------------------------