NETGetHostIP

function

Library: Network utilities (OMNETUTL legacy)
Include: omnetutl.xin

Returns: The IP of a host computer given its name.


Declaration
define external stream function NETGetHostIP
   By-Name value string Host-Name optional

Argument definitions

Host-Name
is the name of the host computer you want to retrieve the IP address of.


Purpose

Use NETGetHostIP to retrieve the Internet Protocol (IP) address of a host computer, given its name.

Requirements

You must include the following line at the beginning of your OmniMark program:

  include "omnetutl.xin"

Usage Notes

The IP address is returned in dotted decimal format (for example, "127.0.0.1").

If no host name is specified, NETGetHostIP returns the IP address of the local host. If NETGetHostIP fails to retrieve the IP address, it returns NETInvalidIP which is defined as "255.255.255.255".

Examples

This sample gets the host IP given its name or name alias.

  include "omnetutl.xin"
  
  process
    local stream host
    set host to "www.omnimark.com"
    output "ip of %g(host) is: <" || NETGetHostIP By-Name host || ">%n"

This sample gets the IP of the local host.


  include "omnetutl.xin"
  
  process
  
    output "Local host ip is: <" || NETGetHostIP || ">%n"