PC Review


Reply
Thread Tools Rate Thread

Deriving a new Ping class from System.Net.NetworkInformation.Ping

 
 
Eric Wenger
Guest
Posts: n/a
 
      20th Jul 2005
I'm pretty new to C# and I'm trying to do what I believe should be a
simple thing. I want to modify a program that is using the
System.Net.NetworkInformation.Ping class to have some custom behavior.
For example I would like to do a "TCP-ping" where I try to connect to a
TCP port on a remote machine. It seems obvious to me that I should try
to derive a new Ping class (TCPPing) from the existing class so that I
can use its interfaces.

Unfortunately for me, the PingReply class (returned by Ping.Send())
does not have a constructor and has no settable properties. It seems
like I would have to go into "unsafe" code land to figure out what's
inside but I can't do that either.

Is there a solution to this or do I need to try a different approach?

 
Reply With Quote
 
 
 
 
Cathal Connolly [C# MVP]
Guest
Posts: n/a
 
      20th Jul 2005
As far as I remember the NetworkInformation.Ping class only supports ICMP.
If you want to do a tcp-ping, then you're probably better off looking at
System.Net.Sockets namespace.

http://msdn2.microsoft.com/library/1612451t(en-us,vs.80).aspx (I'm assuming
you're working with one of the CTP or Beta drops of 2.0)

Cathal


"Eric Wenger" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm pretty new to C# and I'm trying to do what I believe should be a
> simple thing. I want to modify a program that is using the
> System.Net.NetworkInformation.Ping class to have some custom behavior.
> For example I would like to do a "TCP-ping" where I try to connect to a
> TCP port on a remote machine. It seems obvious to me that I should try
> to derive a new Ping class (TCPPing) from the existing class so that I
> can use its interfaces.
>
> Unfortunately for me, the PingReply class (returned by Ping.Send())
> does not have a constructor and has no settable properties. It seems
> like I would have to go into "unsafe" code land to figure out what's
> inside but I can't do that either.
>
> Is there a solution to this or do I need to try a different approach?
>



 
Reply With Quote
 
Eric Wenger
Guest
Posts: n/a
 
      20th Jul 2005
Well, that's not really my question. I'm not asking how to do my
TCP-ping but rather how to implement it efficiently in C# .NET. I
would like to be able to re-use the existing interface for Ping and
have the ability in the future to take advantage of polymorphism.

What I am really curious about is Microsoft's decision to clip the
PingReply class so that it cannot be derived. Is there a higher
principle here that I am missing?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenNETCF.Net.NetworkInformation.Ping Harry Simpson Microsoft Dot NET Compact Framework 3 30th Apr 2008 04:27 PM
Ping Class Luke Davis Microsoft C# .NET 2 8th Mar 2008 08:50 PM
ping 127.0.0.1 works. ping 192.168.0.1 (actual IP number) doesn't work. wrreisen@yahoo.com Windows XP Networking 6 29th Aug 2005 02:17 PM
XP system cannot PING itself, but can PING other systems =?Utf-8?B?UklULTg5?= Windows XP Networking 1 17th May 2005 06:48 AM
Interesting problem - ping loop ok but not ping IP address Julian Windows XP Networking 7 28th Oct 2003 04:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.