Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ok so i am really sorry if this has been answered before i am not the best at at VB.net by far anyways i have a problem, i have written some code in a VB i have made that pings a server and give me and MS and writes it on the app, now what i need is it to be able to ping the port in the same equation but i am not sure how and if i can even implement it into my code, the reason behind this is that it pings a game server, so when the servers are not up they close a port,

 

anyways i will put some code here and see if you guys think i can implement it if not any pointers will be greatly appreciated

 


If InternetConnection() = True Then
               Dim p As System.Net.NetworkInformation.Ping = New System.Net.NetworkInformation.Ping
               Dim prep As System.Net.NetworkInformation.PingReply
               'if server = 0 then ping server and 
               If (server = 0) Then
                   Dim url As String = "79.110.94.195"
                   prep = p.Send(url)
                   If (prep.Status = System.Net.NetworkInformation.IPStatus.Success) Then
                       Dim address As String = prep.Address.ToString
                       Dim time As String = prep.RoundtripTime.ToString
                       Label3.Text = (time + " Ms")
                       server_pic.Image = Image.FromFile("config\server_up.png")
                   Else
                       Dim status As String = prep.Status.ToString
                       server_pic.Image = Image.FromFile("config\server_down.png")
                       Label3.Text = ("0 Ms")
                   End If

  • Administrators
Posted

A ping request simply checks if there is something active on the specified IP address, there really isn't the concept of pinging a port.

 

If the ping request succeeds you could try opening a connection on the specified port and see if anything accepts.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)
Yeah I didn't mean to "ping the port " bit through a port number, website allow you to connect to them through port 80 and online games allow you to connect to the servers through for example port 4500, now if the servers are down for some reason they will close off port 4500 to stop people connecting to the server, but my code doesn't ping through any port so even of the game servers are offline for users, my code is still saying they are online because it is not trying to ping through the closed port? Do you understand where I am coming from? Edited by neoryudo

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...