| C# // .NET General discussions about C# and .Net |
|
#1
| ||||
| ||||
| C# ping
ping be it simple is a great tool and sometimes ya may need your program to see if a computer is up so here is some code. Code: using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.NetworkInformation;
namespace ICMP
{
class Program
{
static void Main(string[] args)
{
Ping pingSender = new Ping();
string data = "http://www.intern0t.net";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 1000;
PingOptions options = new PingOptions(64, true);
PingReply reply = pingSender.Send("127.0.0.1", timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Address: {0}", reply.Address.ToString());
Console.WriteLine("Roundtrip time: {0}", reply.RoundtripTime);
Console.WriteLine("Time to live: {0}", reply.Options.Ttl);
Console.WriteLine("Fragment: {0}", reply.Options.DontFragment);
Console.WriteLine("Buffer size: {0}", reply.Buffer.Length);
Console.ReadLine();
}
else
{
Console.WriteLine(reply.Status);
Console.ReadLine();
}
}
}
}
Ping.rar
__________________ "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match". |
|
#2
| ||||
| ||||
| Re: C# ping
Nice, it looks pretty cool. Now build us a ping application where you can modify everything xD Just kidding :-) Nice clean and simple code hehe :-P
__________________ ![]() Quote:
|
|
#3
| ||||
| ||||
| Re: C# ping
xD I kinda did u know where it is.
__________________ "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match". |
|
#4
| ||||
| ||||
| Re: C# ping
Yeah I found it afterwards ;-) hehe
__________________ ![]() Quote:
|
|
#5
| ||||
| ||||
| Re: C# ping
I found that xD. Nice code snippet
__________________ Hacking is not an illegal act. It's an Art |
|
#6
| ||||
| ||||
| Re: C# ping Heh no cause it's not public
__________________ ![]() Quote:
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ping Blazer | hestas | The Offtopic Section | 14 | 26th July 2009 15:40 |
| History Hacks and Ping Sweeping | MaXe | Web Hacking & War Games | 0 | 24th July 2009 20:53 |