CFLib.org – Common Function Library Project

GetHostName(address)

Last updated December 19, 2001
Download UDF

author

Ben Forta                                         Ben Forta

Version: 1 | Requires: ColdFusion 5 | 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:

<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>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson