Jump to content

Check if server is online?


Recoil

Recommended Posts

When I bring up my client it tries to connect before I allow my Play button to be enabled.  I'm checking if the server is up with Connect():

Private Sub tmrConnect_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles tmrConnect.Tick
        Static i As Long
        If IsConnected() Then
            lblServerStatus.ForeColor = Color.Green
            lblServerStatus.Text = "Online"
        Else
            lblServerStatus.ForeColor = Color.Red
            i = i + 1
            If i = 5 Then
                Connect()
                lblServerStatus.Text = "Reconnecting"
                i = 0
            Else
                lblServerStatus.Text = "Offline"
            End If
        End If
    End Sub

What happens is I get a connection to the server.  When I log in I get another connection to the server.  When I log out I lose 2 connections from the server.  I know how to ping the ip, but I cannot check the ping through that method.  How would I check if the server is actually up, like a peek method, without creating a connection, or at least be able to close the connection?

Link to comment
Share on other sites

Best method is to use the existing connection when logging in. Server is online if socket is connected. Even if you used the ping class, you wouldn't be testing the actual port or if an Orion server is actually there.

Link to comment
Share on other sites

Connect() is being called 3 times.  If I use my connect only, and comment out the one in ClientGenral->ConnectToServer and sub Startup, when it obtains a connection where I am calling it, then it allows the button to be clicked.  I go and login with my char, and the server says "admin has logged in from xxx.xxx.x.x".  When I close this out it still disconnect 2 of the same ip connections.

It isn't a problem, I can bypass these exceptions and it work fie.  I'm just trying to resolve all these connection errors I am getting when there is no client for the server to close the connection.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...