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

  • Thread starter Thread starter Eric Wenger
  • Start date Start date
E

Eric Wenger

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?
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top