Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

code to make a server status checker

Upon pressing a button in VBNET I want it to report the status to the server either returning "online" or "offline" after checking the status. Does anyone have a clue how I could code this or have the code for this?
you can easily do with with webrequests with sites like downorjustme, or you can ping it.
(Jun 29, 2012 12:02 AM)๖ۣۜMephobia Wrote:  you can easily do with with webrequests with sites like downorjustme, or you can ping it.
Yes, but do you have the code to do such? I would like the users to be able to check the status from within the program.
Place a button on your panel, and a textbox, then write the following code :

Code
If my.computer.network.ping(Textbox1.text THE IP HERE) Then
msgbox("online")
else
msgbox("offline")
Code
Try
HttpWebRequest request = new HttpWebRequest(WebRequest.Create("IP"))
Dim reader as new StreamReader(request.GetStream())
HttpWebResponse response = new HttpWebResponse(reader)
Catch

End Try

Or some shit like that, idk.
here ya go
Code
Try
Dim src As String = New StreamReader(HttpWebRequest.Create("http://www.downforeveryoneorjustme.com/" & website.Text).GetResponse.GetResponseStream).ReadToEnd
  If src.Contains("It's not just you!") Then
    status.Text = "Website is down"
  Else
    status.Text = "Website is up"
  End If
Catch ex as Exception
  MessageBox.Show(ex.Message)
End Try

u can use webclient instead of webrequest
EDIT:
it would be
Code
If New WebClient().DownloadString(New Uri("http://www.downforeveryoneorjustme.com/facebook.com")).Contains("It's not just you!") Then
    status.Text = "Website is down"
  Else
    status.Text = "Website is up"
End If
replace "facebook.com" with the website
Code
Private Function Status(ByVal site As String)
  If New System.Net.WebClient().DownloadString(String.Format("http://www.downforeveryoneorjustme.com/{0}", site).Contains("It's just")) Then Return True Else Return False
    End Function
(Jun 29, 2012 12:25 AM)ytlayol Wrote:  here ya go
Code
Try
Dim src As String = New StreamReader(HttpWebRequest.Create("http://www.downforeveryoneorjustme.com/" & website.Text).GetResponse.GetResponseStream).ReadToEnd
  If src.Contains("It's not just you!") Then
    status.Text = "Website is down"
  Else
    status.Text = "Website is up"
  End If
Catch ex as Exception
  MessageBox.Show(ex.Message)
End Try

u can use webclient instead of webrequest
EDIT:
it would be
Code
If New WebClient().DownloadString(New Uri("http://www.downforeveryoneorjustme.com/facebook.com")).Contains("It's not just you!") Then
    status.Text = "Website is down"
  Else
    status.Text = "Website is up"
End If
replace "facebook.com" with the website

Some of the sites block downforjustme type sites.

For EG: Hackforums.
So it's better you use Ping.
Thanks guys, much love. Helped me alot! Working on my first project.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SIM-4173254Sep 18, 2020 09:18 AM 5 140 Sep 18, 2020 09:18 AM
Last Post: SIM-4173254
[C#] by DotexeAug 5, 2017 04:23 PM 0 154 Aug 5, 2017 04:23 PM
Last Post: Dotexe
[.NET] by Egregious Jr.Nov 8, 2016 02:03 PM 15 289 Nov 8, 2016 02:03 PM
Last Post: Egregious Jr.