|
-
Oct 5th, 2008, 02:02 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Simple Service Status?
Hello all,
I have been racking my brain for a few days now trying to think of a simple way to do this, looked up examples, but havnt quite found what im looking for.
I am looking for a simple way of seeing if a service is either online or off.
Service = Web Based.
For example,
if www.gixxerpc.com is accessible then return the code: ok
if its not, then return the code: "down"
I was thinking of basically having a text file looking for a .txt file on the said server that said "ok", because if it was down, then it'd return the html code saying it cant be viewed. Which would result in the 'else', and Id know if its down.
However, the reason why id like to go against this, is so I can set it up to ping specific ports/ip's without having to upload a specific file.
Thank you for your help in advance
-
Oct 6th, 2008, 01:38 AM
#2
Hyperactive Member
Re: Simple Service Status?
Code:
Public Function IsConnectionAvailable() As Boolean
' Returns True if connection is available
' Replace www.yoursite.com with a site that
' is guaranteed to be online - perhaps your
' corporate site, or microsoft.com
Dim objUrl As New System.Uri("http://www.yahoo.com/")
' Setup WebRequest
Dim objWebReq As System.Net.WebRequest
objWebReq = System.Net.WebRequest.Create(objUrl)
Dim objResp As System.Net.WebResponse
Try
' Attempt to get response and return True
objResp = objWebReq.GetResponse
objResp.Close()
objWebReq = Nothing
Return True
Catch ex As Exception
' Error, exit and return False
objResp.Close()
objWebReq = Nothing
Return False
End Try
If you found any of my posts helpful then please rate them.
CodeBank
Form Fading Effects in VB.NET and C#
-
Oct 6th, 2008, 07:10 PM
#3
Thread Starter
Fanatic Member
Re: [RESOLVED] Simple Service Status?
Works beautifully, had to change some things.
Had to return the "objresp.close()" and the "objwebreq = nothing" from the catch ex as exception part. But all works perfect. Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|