IT Community - Software Programming, Web Development and Technical Support

How can Ping Gateway in c#.net

This is a discussion on How can Ping Gateway in c#.net within the C# Programming forums, part of the Software Development category; Hi all, Any one can help me for Gateway ping with programatecaly. Gateway ping not a IP Address Ping....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-04-2008, 04:56 AM
Mramesh Mramesh is offline
D-Web Sr.Programmer
 
Join Date: Sep 2007
Location: Chennai
Posts: 106
Mramesh is on a distinguished road
Send a message via MSN to Mramesh
Default How can Ping Gateway in c#.net

Hi all,
Any one can help me for Gateway ping with programatecaly.
Gateway ping not a IP Address Ping.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-04-2008, 04:59 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Default Re: How can Ping Gateway in c#.net

Hi Ramesh,

Ping remote computer in the network

Normally we use dos command “ping” to know connection status of the remote machine, the same thing we can do using “System.Net.NetworkInformation.Ping” class. Using this class we can check the remote machine connected with the current machine or not. Also we can use “PingOptions” class to give the options to ping.

Regarads
Deeban A

Last edited by a.deeban : 01-04-2008 at 05:11 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-04-2008, 05:10 AM
Sundaram Sundaram is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Location: chennai
Posts: 117
Sundaram is on a distinguished road
Send a message via MSN to Sundaram Send a message via Yahoo to Sundaram
Default Re: How can Ping Gateway in c#.net

hi deeban,

Can u give the sample code to ping a computer in the network.

Tanx in Advance..

Sundram

Last edited by Sundaram : 01-04-2008 at 05:12 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-04-2008, 05:15 AM
a.deeban a.deeban is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 279
a.deeban is on a distinguished road
Default Re: How can Ping Gateway in c#.net

Import Namespaces :

Code:
using System.Net.NetworkInformation;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms
Here’s the sample code to ping a computer in your network.

Code:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        string remoteMachineNameOrIP= "192.1.168.1";
        int timeOut = 5;

        Ping ping = new Ping();

        // Pinging remote maching
        PingReply reply = ping.Send(remoteMachineNameOrIP, timeOut);

        // Displaying the result
        StringBuilder sb = new StringBuilder();
        sb.Append("Address:" + reply.Address.ToString());
        sb.Append("\nStatus:" + reply.Status.ToString());
        sb.Append("\nRoundtripTime:" + reply.RoundtripTime.ToString());

        MessageBox.Show(sb.ToString(), "Ping Result: " + remoteMachineNameOrIP);
    }
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to ping IM thru asp.net rrrajesh84in ASP and ASP.NET Programming 3 01-09-2008 09:48 PM
send the sms using SMS/MMS Gateway in php varghese PHP Programming 1 09-18-2007 08:32 AM
Payment Gateway vadivelanvaidyanathan Software Testing 0 09-12-2007 04:15 AM
Need help on payment gateway integration in a website using C# garunprasad C# Programming 1 08-01-2007 04:44 AM
Payment Gateway Jeyaseelansarc PHP Programming 3 07-11-2007 03:20 AM


All times are GMT -7. The time now is 02:38 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0