473,851 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deriving a new Ping class from System.Net.Netw orkInformation. Ping

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.Netw orkInformation. 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?

Nov 17 '05 #1
2 5608
As far as I remember the NetworkInformat ion.Ping class only supports ICMP.
If you want to do a tcp-ping, then you're probably better off looking at
System.Net.Sock ets namespace.

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

Cathal
"Eric Wenger" <er*********@ya hoo.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
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.Netw orkInformation. 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?

Nov 17 '05 #2
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?

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1416
by: Willy Bilaro | last post by:
Is there ping object. or is it method of another object.
3
2040
by: schaf | last post by:
hi NG ! My app knows the IP address of a remote computer from App.exe.config. What's the best way to check if this pc in on the network ? Ping ? or Dns.GetHostByAddress(sRemoteHostDefinition).HostName and catch the exception ? Thanks
1
18528
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking whether the application is able to access the webservice. If the webservice is accessible, the application is online. otherwise it is offline What is the best way to ping a url in C# ?
5
6590
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I try to ping another PC using ping in vb 2005, can anyone provide a snippet of code? Thanks in advance, Martin
4
13207
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all I need a simple program that allows me to check if an IP address is pingable. I am not going to send/receive anything to the remote host, just check if it is visible. Something like this: private bool CheckIPAddress(string address) { if (Ping(address))
2
5971
by: Jason | last post by:
I would like to make a simple PING program that has the following paremeters: txtAddress - a text-box that you enter an IP address into txtinterval - a text box that allows you to enter in an interval as to when to ping that address. So say I want the values to be between 30 and 420 seconds. So if I enter 30 in the box it will ping every 30 seconds. also a button btnDoIt - when this is pressed it will send 3 or 4 PINGS
4
2724
by: TBoon | last post by:
how do you do a "PING" in vb.net? any samples?
2
1768
by: foster99 | last post by:
I am new to VB.NET and I want to implement a timer function into a PING, below is the code which I am using to PING an ip address. I want the PING to be executed something like every 10 seconds, so that it updates a lablel. Any ideas how to do this? Dim ping As New System.Net.NetworkInformation.Ping Dim options As New System.Net.NetworkInformation.PingOptions options.DontFragment = True
4
2248
by: Newbie | last post by:
Is it possible, without any 3rd party tools to simply ping an ip address, and get back if the ping was sucessfull. Thanks
0
11019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9506
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7906
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5736
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5933
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4549
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4143
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.