Welcome to Hackers Alliance!

[VB.NET] Checking Online Availability with IP and Port

  • Archived

    The forum is archived and used for testing. It is currently read-only to visitors.
    It has been upgraded from vBulletin 3.8.x to XenForo for security purposes and future-proofing. Proprietary code and modifications (such as code database and HA bot) are broken with XenForo and will stay only with vBulletin.

1UP

New member
Nov 3, 2010
66
3
0
33
A while back I was making a launcher for a game server I was working on. And in order for the launcher to launch the game it had to go out and check to see if the servers were even online to begin with. Well I'll show you how I did that here:

We'll start with the imports
Code:
Imports System.Net.Sockets
Now for the variables
Code:
Dim logonServer As New TcpClient()
Code:
Try
            logonServer.Connect("168.144.77.91", 2106)
          
        Catch generatedExceptionName As Exception
            Me.pict_logonServer.BackColor = Color.Red

        End Try
        If logonServer.Connected Then

            Me.pict_logonServer.BackColor = Color.Green
            logonServer.Close()
        End If
This was using a Try catch so if it couldn't make the connection it would drop to Catch then execute whatever is after, in this case it turns the picturebox to red indicating the that server is not running.

If the program was able to connect successfully to the server then for the if statement, it would make the picturebox color Green then close the active connection.

If you plan to put this in form load like I did, I suggest putting it into it's own thread, that way the form launch won't hang as it trys to make the connection.

 

czcool

New member
Aug 24, 2011
1
0
0
nice man i was looking for something like this for a home server etc i have with port but i have a problem i set a timer to make the progress over and over i close the server and the picture stays red i set a label with online/offline text... can you help me a little? :) sorry for bad english :)
 
This site has been archived and is no longer accepting new content.

About us

  • Hackers Alliance is a small community forum about gaming and console hacking. Join our humble community to share ideas, game cheats, mods, and be part of an amazing growing community!

Quick Navigation

User Menu