ColdFusion Muse

More Connection Magic

Mark Kruger February 2, 2009 11:36 PM Coldfusion Troubleshooting Comments (1)

I outlined some issues in my last post on using CFHTTP and paying attention to connection issues. Muse reader Scott Pinkston posted a nice snippet of code that allows you to see what IP address is used to resolve a given domain name. Here it is complete with the function call (getHostAddress()) that gives you the IP address:

<h4>CF Sees the Servername as...</h4>

<cfset javaInet = createObject("java","java.net.InetAddress")>

<cfset dnsLookup = javaInet.getByName("test.riaforge.com")>

<Cfdump var="#dnslookup.getHostAddress()#"/>

In fact, if you are on a windows domain and using "friendly" names (names that come without fully qualified domain syntax) this code can resolve those as well, as in this example:

<h4>CF Sees the Servername as...</h4>

<cfset javaInet = createObject("java","java.net.InetAddress")>

<cfset dnsLookup = javaInet.getByName("MUSE-LPTP-2")>

<Cfdump var="#dnslookup.getHostAddress()#"/>

I suppose that Java uses the underlying stack and windows domains typically use windows DNS which are capable of resolving these types of friendly names as well as fully qualified names.

Anyway, this approach came in handy recently when file access to a UNC path (i.e. \\servername\sharename) was throwing a nondescript error. The error could have been permissions or name resolution (we weren't sure). Using the code above to resolve the "servername" portion of the UNC path we were able to test resolution to make sure it was returning the correct IP.

  • Share:

1 Comments

  • chris hough's Gravatar
    Posted By
    chris hough | 1/9/12 12:29 PM
    thank you so much for posting this, it was very helpful in putting together a method I have been working on. cheers.