Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get the server status???
#1
Hello guys,

I want my software that it will contain a server status dialog. When a user will click on the server status then a dialog will open in which they will be able to see if the MySQL server with this software in online or offline.

I need a code that will open a db connection and if connection open the show a circle with green color and say green color Online and if db connection timeout then they will get a the circle red and red Offline text and this will happen if their internet connection is not available....and if their internet connection available but my MySQL server is down then they will get a yellow color on the circle and will say server offline...

Please provide me the code by which I can do this...

Thanks in advance.....
#2
I need to get the server status my db connection not by ping method.

Another:
I need another solution on this that how can I ping any server and if ping successful then circle will be green and if ping timed out then circle will be yellow and if destination unreachable then the circle will be red and if the domain or ip doesn't exist then it will say plzzz enter a valid ip or domain.....
#3
Checking if the computer is conected to the internet:

[code2=vbnet]If My.Computer.Network.IsAvailable = True Then
MsgBox("Your computer is conected", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Information")
Else
MsgBox("Your computer is not conected", MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical, "Information")
End If[/code2]

Pinging a host:

First import System.Net and System.Net.NetworkInformation:


[code2=vbnet]Imports System.Net, System.Net.NetworkInformation[/code2]
Then ping with the folowing code:
[code2=vbnet]Sub Ping()

Dim ping As New Ping()
Dim reply As PingReply
Dim _byte As Byte() = BitConverter.GetBytes(32)

Try
reply = ping.Send(Host, 1000, _byte)

Select Case reply.Status
Case IPStatus.Success
' code for succesfull ping
Case IPStatus.TimedOut
' code for ping timeout
Case IPStatus.BadDestination
'code for bad adress
Case Else
'code for other ocurences
' you can put a MsgBox that will say that something else happened
'MsgBox("Please check code", MsgBoxStyle.Exclamation, "Ping Status")
End Select

Catch pex As PingException
MsBox(pex.ToString)
Exit Sub
Catch ex As Exception
MsgBox(ex.ToString)
End Try[/code2]

Now before you reply to this post saying that the code above does not work replace "Host" with the actual ip of the web site.

For the third problem , checking if MySql server is online or not, that is also simple because usualy MySql has a default port number and its just a case of connecting a TcpClient to that ip and port and if it connects it means it is online.

Here are the steps to do just that:
First , just as above import System.Net And System.Net.Sockets(i'm not going to show how to do it again)

Second Use this code snippet:

[code2=vbnet]Private Sub CheckServerStatus()
Try
Dim TcpCl As New TcpClient
Dim IpEP As New IPEndPoint(IPAddress.Parse("IP"), 3306) 'if i'm not mistaking 3306 is the default port for Mysql Server
TcpCl.Connect(IpEP)
If TcpCl.Connected Then
'code for serve online
TcpCl.Close()
End If
Catch ex As Exception
'code for server offline
End Try
End Sub[/code2]

Replace "IP" with the ip of the server you are trying to connect. REMEMBER THE "IP" HAS TO BE A STRING !!!
Sssssssssoftware developer...
#4
bro i already told in my post that i don't need the ping method for my db server status....i need the server status form to open a db connection and if failed then make a circle yellow and if the computer is not connected with the internet then it will make the circle red and if db connection ok then it will make the circle green...

i could have used the ping method but my server allow no pinging to it.....
#5
Read the third block of code , it has nothing to do with pinging a host , it's a simple TcpClient that conects to the web site on a spcific IP and PORT number
Sssssssssoftware developer...
#6
thanks bro...
your code worked successfully but can i add another status on the code...like

now i am getting a status for server online and another status for server offline and also for computer in n0t connected with the internet....

can u please provide me the code to get these three status...

Thanks in advance....


Possibly Related Threads…
Thread Author Replies Views Last Post
  multiple csv files add sql server tables via VB.NET secilsengul 1 9,979 04-16-2014, 10:27 AM
Last Post: brco900033
  Downloading from FTP server doesn't work brco900033 5 21,859 08-16-2013, 04:32 AM
Last Post: brco900033
  Is this possible with SQL Server? Worf 2 12,338 02-25-2013, 03:04 AM
Last Post: Worf
  Sockets Programming(Disconnecting from Server) xolara 1 9,436 04-06-2012, 01:47 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)