CFLib.org – Common Function Library Project

GetHostName(address)

Last updated December 19, 2001

author

Ben Forta

Version: 1 | Requires: CF5 | Library: NetLib

Description:
DNS lookup, provide an IP address, it'll return a host name. If the address is invalid an exception will be throw, so <CFTRY>/<CFCATCH> should be used.

Return Values:
Returns a domain name.

Example:

<CFOUTPUT>
#GetHostName(CGI.REMOTE_ADDR)#<br>
<i>Note, since we cache pages, the result of this test will not reflect your remote address.</i>
</CFOUTPUT>

Parameters:

Name Description Required
address IP address to look up. Yes

Full UDF Source:

/**
 * Performs a DNS lookup on an IP address.
 * 
 * @param address      IP address to look up. 
 * @return Returns a domain name. 
 * @author Ben Forta (ben@forta.com) 
 * @version 1, December 19, 2001 
 */
function GetHostName(address) {
   // Variables
   var iaclass="";
   var addr="";
   
   // Init class
   iaclass=CreateObject("java", "java.net.InetAddress");

   // Get address
   addr=iaclass.getByName(address);

   // Return the name    
   return addr.getHostName();
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson