****************************************
      * Program name: gethn.cbl
      * This program demonstrates how to use
      * the GETHOSTNAME and GETHOSTBYNAME
      * commands.
      * The GETHOSTNAME command retrieves
      * the name of this machine from the
      * operating system.
      * The GETHOSTBYNAME command queries
      * your DNS and retrieves information
      * about a specific hostname or IP
      * address.
      *
      * Copyright 2000 Deskware, Inc.
      ****************************************                                                             
      * Syntax: GETHOSTNAME USING .
      *
      *
      * Syntax: GETHOSTBYNAME USING .
      *
      * Include the TCP/IP variable copybook.
       COPY `tcpip.cpy`.
      
       1 host_name        PIC X(80).

       GETHOSTNAME USING host_name.
       DISPLAY `GETHOSTNAME: ` & host_name.
       DISPLAY `TCPIP-RETURN-CODES: `  & TCPIP-RETURN-CODES.

      * Demonstrate how to use the GETHOSTBYNAME command 
      * with a fullyqualified domain name.
       MOVE `www.cobolscript.com` TO host_name.
       GETHOSTBYNAME USING host_name.
       DISPLAY `TCPIP-HOSTENT-HOSTNAME: `  & TCPIP-HOSTENT-HOSTNAME.
       DISPLAY `TCPIP-HOSTENT-ADDRESS-TYPE: `  & TCPIP-HOSTENT-ADDRESS-TYPE.
       DISPLAY `TCPIP-HOSTENT-ADDRESS-LENGTH: `  & TCPIP-HOSTENT-ADDRESS-LENGTH.
       DISPLAY `TCPIP-RETURN-CODES: `  & TCPIP-RETURN-CODES.
       DISPLAY `TCPIP-HOSTENT-NUM-ADDRESSES: `  & TCPIP-HOSTENT-NUM-ADDRESSES.
       DISPLAY `TCPIP-HOSTENT-ADDRESS(1): `  & TCPIP-HOSTENT-ADDRESS(1).
       DISPLAY `TCPIP-HOSTENT-NUM-ALIASES: `  & TCPIP-HOSTENT-NUM-ALIASES.
       DISPLAY `TCPIP-HOSTENT-ALIAS(1): `  & TCPIP-HOSTENT-ALIAS(1).

      * Demonstrate how to use the GETHOSTBYNAME command with
      * an IP address.
       MOVE `209.249.147.101` TO host_name.
       GETHOSTBYNAME USING host_name.
       DISPLAY `TCPIP-HOSTENT-HOSTNAME: `  & TCPIP-HOSTENT-HOSTNAME.
       DISPLAY `TCPIP-HOSTENT-ADDRESS-TYPE: `  & TCPIP-HOSTENT-ADDRESS-TYPE.
       DISPLAY `TCPIP-HOSTENT-ADDRESS-LENGTH: `  & TCPIP-HOSTENT-ADDRESS-LENGTH.
       DISPLAY `TCPIP-RETURN-CODES: `  & TCPIP-RETURN-CODES.
       DISPLAY `TCPIP-HOSTENT-NUM-ADDRESSES: `  & TCPIP-HOSTENT-NUM-ADDRESSES.
       DISPLAY `TCPIP-HOSTENT-ADDRESS(1): `  & TCPIP-HOSTENT-ADDRESS(1).
       DISPLAY `TCPIP-HOSTENT-NUM-ALIASES: `  & TCPIP-HOSTENT-NUM-ALIASES.
       DISPLAY `TCPIP-HOSTENT-ALIAS(1): `  & TCPIP-HOSTENT-ALIAS(1).