function
Library: Network utilities (OMNETUTIL)
Import : omnetutl.xmd |
Returns: The IP address of a host computer given its name. |
define external stream function netutil.host-ip of value string Host-Name optional
Argument definitions
Use netutil.host-ip to retrieve the Internet Protocol (IP) address of a host computer, given its name.
The IP address is returned in dotted decimal format (for example, "127.0.0.1").
If no host name is specified, netutil.host-ip
returns the IP address of the local host. If netutil.host-ip
fails to retrieve the IP address, it returns netutil.invalid-ip
which is defined as "255.255.255.255".
This sample gets IP address of the host whose host name or alias is specified.
import "omnetutil.xmd" prefixed by netutil. process local stream host initial {"www.stilo.com"} output "The IP address of " || host || " is: " || netutil.host-ip of host || "%n"
This sample gets the IP address of the local host.
import "omnetutil.xmd" prefixed by netutil. process output "The IP address of this machine is: " || netutil.host-ip || "%n"