CFLib.org – Common Function Library Project

GetHostName(address)

Last updated December 19, 2001

Version: 1 | Requires: ColdFusion 5 | Library: NetLib

 
Rated 4 time(s). Average Rating: 2.8

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:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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();
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
10 day(s) ago

Will Belden Will Belden added
longTime
15 day(s) ago

James Sleeman James Sleeman added
quickSort
25 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
28 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson