Network Topics include: sockets, protocols and the web

Go Back  Xtreme .NET Talk > .NET > Network > Ping Server with port


Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2012, 12:13 PM
neoryudo neoryudo is offline
Newcomer
 
Join Date: Apr 2012
Posts: 2
neoryudo is on a distinguished road
Default Ping Server with port



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

Code:
 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
Reply With Quote
  #2  
Old 04-11-2012, 04:24 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Sep 2002
Location: Lancashire, UK
Posts: 6,461
PlausiblyDamp is on a distinguished road
Default Re: Ping Server with port

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
Reply With Quote
  #3  
Old 04-12-2012, 01:38 AM
neoryudo neoryudo is offline
Newcomer
 
Join Date: Apr 2012
Posts: 2
neoryudo is on a distinguished road
Default

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?

Last edited by neoryudo; 04-12-2012 at 01:47 AM.
Reply With Quote
  #4  
Old 04-12-2012, 04:45 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Sep 2002
Location: Lancashire, UK
Posts: 6,461
PlausiblyDamp is on a distinguished road
Default Re: Ping Server with port

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.
__________________
Posting Guidelines FAQ Post Formatting

Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Connectiobn to SQL Server 2005 over non-standard port... SteveoAtilla Database / XML / Reporting 1 08-07-2008 02:08 PM
Ping Class - Assinchronous ping teixeira Network 2 08-29-2006 09:34 AM
Check What Server Is Running On Open Port? samer_ali Network 2 02-17-2004 11:01 PM
Ping and Open Port larnauth Network 1 12-08-2003 07:05 PM
Ping Jay1b Network 10 10-25-2003 12:14 AM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe