neoryudo Posted April 11, 2012 Posted April 11, 2012 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 Quote
Administrators PlausiblyDamp Posted April 11, 2012 Administrators Posted April 11, 2012 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
neoryudo Posted April 12, 2012 Author Posted April 12, 2012 (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 April 12, 2012 by neoryudo Quote
Administrators PlausiblyDamp Posted April 12, 2012 Administrators Posted April 12, 2012 You could probably try using a TcpClient to open a connection to the correct port and see if it connects, if it fails to open then the server is probably offline. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.