hostnameresolver TacHostnameResolver component
Hierarchy Properties Methods Events
Return to Introduction  Previous page  Next page
The acHostnameResolver component used to retrieve the host name by IP address or list of IP addresses, without freezing your application (it resolves hostnames in separate thread, because this lookup process can take rather long time and may completely freeze your application).  
This component contains the internal cache for host names which arelady resolved, so it can quickly lookup for cached hostname and not use additional CPU time and bandwidth to resolve the same IP serveral times at row. Plus, the cache can be stored in system registry for further use after program restart.  
Also, the acHostnameResolver can be used as simple monitor to check whether Internet connection is active, and to be notified when current PC goes online or offline (online status changes).  
How to use?
You just need to specify the IP address or list of IP addresses to IPList property. If the AutoResolve is True, the specified IPs will be resolved each time when the list is updated (when you add new IP to the IPList queue). Otherwise, if AutoResolve is False, you need programmatically call Execute method to start lookup process.  
Each time when component finished IP lookup, it triggers OnHostNameRetrieved event. Write this event handler to get the hostname and determinate its original IP address.  
Note that component contains the internal cache for hostnames which already resolved. The size of the cache controlled by CacheSize property (maximum number of records which cache can contain). If CacheSize = 0, the component does not use cache at all. The cache can be stored to the registry for further use after program restarts. To enable saving/restoring of cached records, set RegistrySaver's Enabled property to True and specify the key where to store records in RegKey property.  
Also, if you wish to quickly hostname which was already resolved from cache, you can use ResolveCachedIP method.  
tip Additionally, the component can determinate current online status of machine (IsOnline property), and monitor it when computer goes online or offline (user connected or disconnected from Internet). If you wish to constantly check whether Internet connection available — use MonitorActive and MonitorInterval properties. To be notified when online status changes — write OnOnlineStatusChanged event handler.