Hack Forums
[.NET] code to make a server status checker - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] code to make a server status checker (/showthread.php?tid=2630925)



code to make a server status checker - _WiZ_ - Jun 28, 2012

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?


* - ๖ۣۜMephobia - Jun 29, 2012

you can easily do with with webrequests with sites like downorjustme, or you can ping it.


* - _WiZ_ - Jun 29, 2012

(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.


* - MaxPain - Jun 29, 2012

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")



* - Hunter S Thompson - Jun 29, 2012

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.


* - ytlayol - Jun 29, 2012

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


* - Coleak - Jun 29, 2012

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



* - Mr Kewl - Jun 29, 2012

(Jun 29, 2012 12:25 AM)loyalty 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.


* - _WiZ_ - Jun 29, 2012

Thanks guys, much love. Helped me alot! Working on my first project.