CFLib.org – Common Function Library Project

Ping(host)

Last updated October 14, 2008

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

 
Rated 3 time(s). Average Rating: 4.0

Description:
Sometime you would like to ping URLs to check their availability just like using windows run command ping <ip/url>

Return Values:
A string containing the results of the ping.

Example:

view plain print about
<h3>Ping Test</h3>
<cfoutput>
    Almontel 1: #Ping("www.almontel1.com")#<br>
    Almontel 2: #Ping("www.almontel2.com")#<br>
</cfoutput>

Parameters:

Name Description Required
host URL/IP that you would like to ping. Yes

Full UDF Source:

view plain print about
<!---
 Pings a website using .net framework
 
 @param host      URL/IP that you would like to ping. (Required)
 @return A string containing the results of the ping. 
 @author Elias (eliasjp@msn.com) 
 @version 1, October 14, 2008 
--->

<cffunction name="Ping" returntype="string" output="false" access="public">
    <cfargument name="host" type="string" required="yes">
    <!--- Local vars --->
    <cfset var pingClass="">
    <cfset var pingReply="">
    <!--- Get Ping class --->
    <cfobject type=".NET" name="pingClass"
            class="System.Net.NetworkInformation.Ping">

    <!--- Perform synchronous ping (using defaults) ---> 
    <cfset pingReply=pingClass.Send(Arguments.host)>
    <!--- Return result --->
    <cfreturn pingReply.Get_Status().ToString()>
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

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

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

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

Ben Forta Ben Forta added
GetHostAddress
22 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