hello ,
I use the following method to find out if a remote computer in an
intranet is connected or not on the intranet network...

but the following is very long at least 10-11s per host

are there any other know methods

thank for your help
Franck

using System.Net;
public static void pinger(string hostname,ref bool found)
{
try
{
Dns.GetHostByName(hostname);
}
catch(System.Net.Sockets.SocketException )
{
found=false;
}
catch(System.Security.SecurityException )
{
found=true;
}
catch(Exception excep)
{
found=false;
}
found=true;
}

Re: found out if a remote computer is on the intranet network ? by Michael

Michael
Wed Nov 09 11:35:52 CST 2005

Hi Franck,

you may try the following to see if it is faster:

using System.Management;



string Ping(string address) {

ManagementObjectSearcher searcher =

new ManagementObjectSearcher("root\\CimV2", "Select * From
Win32_PingStatus where Address = '" + address + "'");

ManagementObjectCollection objects = searcher.Get();

if (objects != null) {

foreach (ManagementObject mo in objects) {

object statusCode = mo["StatusCode"];

if ((statusCode != null) && ((uint) statusCode == 0)) {

return (string) mo["ProtocolAddress"];

}

}

}

return null;

}


This method will either return the ip address of the host specified in the
address parameter (host name orip address) or null, if the ping did not
succeed.

Michael

"Franck" <fh@fh.com> schrieb im Newsbeitrag
news:dkt91g$ai6$1@s1.news.oleane.net...
> hello ,
> I use the following method to find out if a remote computer in an intranet
> is connected or not on the intranet network...
>
> but the following is very long at least 10-11s per host
>
> are there any other know methods
>
> thank for your help
> Franck
>
> using System.Net;
> public static void pinger(string hostname,ref bool found)
> {
> try
> {
> Dns.GetHostByName(hostname);
> }
> catch(System.Net.Sockets.SocketException )
> {
> found=false;
> }
> catch(System.Security.SecurityException )
> {
> found=true;
> }
> catch(Exception excep)
> {
> found=false;
> }
> found=true;
> }



Re: found out if a remote computer is on the intranet network ? by Franck

Franck
Wed Nov 09 11:47:23 CST 2005

Thanks for your
help but it is lasting the same....

Michael Höhne wrote:
> Hi Franck,
>
> you may try the following to see if it is faster:
>
> using System.Management;
>
>
>
> string Ping(string address) {
>
> ManagementObjectSearcher searcher =
>
> new ManagementObjectSearcher("root\\CimV2", "Select * From
> Win32_PingStatus where Address = '" + address + "'");
>
> ManagementObjectCollection objects = searcher.Get();
>
> if (objects != null) {
>
> foreach (ManagementObject mo in objects) {
>
> object statusCode = mo["StatusCode"];
>
> if ((statusCode != null) && ((uint) statusCode == 0)) {
>
> return (string) mo["ProtocolAddress"];
>
> }
>
> }
>
> }
>
> return null;
>
> }
>
>
> This method will either return the ip address of the host specified in the
> address parameter (host name orip address) or null, if the ping did not
> succeed.
>
> Michael
>
> "Franck" <fh@fh.com> schrieb im Newsbeitrag
> news:dkt91g$ai6$1@s1.news.oleane.net...
>
>>hello ,
>>I use the following method to find out if a remote computer in an intranet
>>is connected or not on the intranet network...
>>
>>but the following is very long at least 10-11s per host
>>
>>are there any other know methods
>>
>>thank for your help
>>Franck
>>
>>using System.Net;
>> public static void pinger(string hostname,ref bool found)
>> {
>> try
>> {
>> Dns.GetHostByName(hostname);
>> }
>> catch(System.Net.Sockets.SocketException )
>> {
>> found=false;
>> }
>> catch(System.Security.SecurityException )
>> {
>> found=true;
>> }
>> catch(Exception excep)
>> {
>> found=false;
>> }
>> found=true;
>> }
>
>
>