Post: [VB.NET] Checking Online Availability with IP and Port
10-28-2010, 10:59 PM #1
Default Avatar
Oneup
Guest
(adsbygoogle = window.adsbygoogle || []).push({}); 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
    Imports System.Net.Sockets


Now for the variables
     
Dim logonServer As New TcpClient()


            
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.

You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked Oneup for this useful post:

Shadow517

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo