C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Ping remote computer in the network


Posted Date: 27 Mar 2007    Resource Type: Code Snippets    Category: Network

Posted By: Manikandan Balakrishnan       Member Level: Gold
Rating:     Points: 10



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.

Here’s the sample code to ping a computer in your network.


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);
}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Building a Simple File download server using C#
Previous Resource: Retrieving TCP connections information
Return to Discussion Resource Index
Post New Resource
Category: Network


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

SPOC

Contact Us    Privacy Policy    Terms Of Use