xHarbour Reference Documentation > Function Reference |
Queries IP addresses associated with a name.
INetGetHosts( <cHostName> ) --> aIPAddresses
The function returns an array filled with character strings holding IP addresses in dotted notation. If a network error occurs, the function returns NIL.
Function INetGetHosts() is used to resolve IP addresses from a host name. The IP addresses associated with a host name are collected in an array which is returned. The IP addresses are stored as character strings in dotted notation. These strings can be passed to INetConnectIP() for establishing a connection to a host.
Note: INetGetHosts() function is not thread safe by design. A programmer must be sure not to call it simultaneousley at the same time in two different threads, and not to use it at the same time as InetConnect(). If such a simultaneous call cannot be avoided. a call to INetGetHosts() and/or INetConnect() must be protected with a mutex.
See also: | INetAddress(), INetConnect(), INetGetAlias() |
Category: | Internet functions , Sockets functions , xHarbour extensions |
Source: | vm\INet.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example dispays the IP addresses of a local and a remote host. PROCEDURE Main LOCAL aIP INetInit() aIP := INetGetAlias( "www.xHarbour.com" ) ? ValToPrg( aIP ) // result: { "193.239.210.10" } aIP := INetGetAlias( "localhost" ) ? ValToPrg( aIP ) // result: { "127.0.0.1" } INetCleanUp() RETURN
http://www.xHarbour.com