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>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson