• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

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

1UP

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

aionlaunch.jpg
 
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.

aionlaunch.jpg
Thanks for supporting the community ;)
 
Omg this is so awesome thanks for sharing :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • @ QM|T_JinX:
    hope you have a great night bro
  • @ God:
    It was good talking with you as well, you have a great night! We will talk later bro
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ QM|T_JinX:
    have a great weekend everybody ill be back after the weekend
  • Chat Bot:
    OkBrruh is our newest member. Welcome!
  • Chat Bot:
    uncrtin is our newest member. Welcome!
  • Chat Bot:
    BigTechModz is our newest member. Welcome!
  • @ BigTechModz:
    Hey this is RexMods I don’t remember the login to my old account so I made a new one I am now known as BigTechModz
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    iDior2K is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    KillerDino49 is our newest member. Welcome!
  • Chat Bot:
    Xiomber is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    051magalhães is our newest member. Welcome!
  • Chat Bot:
    wheelcore is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    zeppiemods66 is our newest member. Welcome!
  • Chat Bot:
    Scrapper is our newest member. Welcome!
  • Chat Bot:
  • Chat Bot:
  • Chat Bot:
    Christo has joined the room.
      Chat Bot: Christo has joined the room.
      Back
      Top