Wednesday, March 7, 2007

ping server by programing

Form one month i'm design Ads with new technology but it's very heavy so that we separate this Ads in different server to protect our original server ok until now i'm don't have any problem but the problem was appear when mr:president request from me to test server that has Ads befor load from it because if it has problem we load on page different ads so
From two weeks or more I skim force internet to search How to solve this problem
but today i found alot of solution for this problem one with sql server but we don't have permission to do it . but I found the excellent solution with asp classic , C# ,VB i thing with any lang
this is solution with VB .net 2005 :
------------------------------------------------------------------
Public Function END_Ping(ByVal url As String) As Boolean
Dim objWShell As Object
objWShell = CreateObject("WScript.Shell")
Dim objCmd As Object
Dim strPResult As Object
objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
objCmd = Nothing : objWShell = Nothing
If InStr(strPResult, "TTL=") > 0 Then
Return True ' in corect
Else
Return False ' in error
End If
End Function

-------------------------------------------------
and this with asp classic

<% url = "www.yahdffdoo.com"
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
set objCmd = nothing: Set objWShell = nothing
if InStr(strPResult,"TTL=")>0 then
Response.Redirect("http://www.googel.com") ' in error
else Response.Redirect("http://www.yahoo.com") ' in corect
end if %>

Thanks Allah for all thing

No comments: