CFLib.org – Common Function Library Project

Ping(host)

Last updated October 14, 2008

author

Elias

Version: 1 | Requires: CF8 | Library: NetLib

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:

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

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

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson