Knowing if a PC is on lan

  • Thread starter Thread starter Zanna
  • Start date Start date
Z

Zanna

Hi all,

I wonder if there is a way to know if in a LAN/WAN a PC (I know the name
or the IP) is reachable.

Is there? :)

Thanks!
 
Zanna:
Hood Canal Systems has a tool written totally in .NET called .NET Preceptor
that's under 15.00 that will determine network connectivity for you.

I wrote an article here
http://www.knowdotnet.com/articles/activesynccradle.html to determine if
your device is cradled (and OpennetCF.org's Rapi library will do this for
you) but cradled and connected on a LAN are two different issues. One way
to do it is to use Leonardo's method in the article of polling a web site
and see if you can make a HTTP Request. This isn't flawless b/c if the web
site is down, you might get a false positive but it's a fairly decent
method.

HTH,

Bill
 
Zanna said:
Hi all,

I wonder if there is a way to know if in a LAN/WAN a PC (I know the name
or the IP) is reachable.

Is there? :)

Thanks!

Zanna,

I know how to do this, but only in eVC++. AFAIK you cannot get this
functionality without P/Invoking the IPHelper API. This solution is only
for Windows Mobile 2003 a.k.a. Pocket PC 2003. If you are interested in
seeing the C++ code to see how it is done reply to my post.
 
Trevor wrote:

I know how to do this, but only in eVC++. AFAIK you cannot get this
functionality without P/Invoking the IPHelper API. This solution is only
for Windows Mobile 2003 a.k.a. Pocket PC 2003. If you are interested in
seeing the C++ code to see how it is done reply to my post.

I found it.

It's really simple:


Dim ip As System.Net.IPHostEntry
Try
ip = System.Net.Dns.Resolve(hostNameOrIP)
// ok, host found
Catch ex As Exception
// host not found: not in lan
End Try

Bye

--
 
Zanna said:
Trevor wrote:



I found it.

It's really simple:


Dim ip As System.Net.IPHostEntry
Try
ip = System.Net.Dns.Resolve(hostNameOrIP)
// ok, host found
Catch ex As Exception
// host not found: not in lan
End Try

Bye

That is close but what if the user has a Pocket PC with 2 radios
installed? It will pick whichever is the default, which is probably not the
one you want. My Pocket PC has an IP even when it is not connected to the
LAN/WAN. It starts with 169.254.xxx.xxx. this may just be my device, but
you should check it out to be sure. BTW, a LAN address will start with
10.xxx.xxx.xxx. You can make your solution a little stronger by checking to
see if you have an IP address and if that IP address starts with 10.xxx.

HTH
 
No! Your IP address can be almost anything (need not start with 10, for
example). You can't look at it and tell if you are connected to the network
or not.

Paul T.
 
Paul said:
No! Your IP address can be almost anything (need not start with 10, for
example). You can't look at it and tell if you are connected to the network
or not.

I don't understand this.

If I search for 192.168.1.255, the procedure above search for this
client and tell if it is reachable (and return the PC name).

Why this does not works?
I don't need to know if *I* am connected, but if *someone*else* is
connected.

BTW... it will be interesting also to know if *I* am connected :) just
to know if I can safely work on the net.

Thanks
bye.
 
Yes, you can search for another machine by IP, but the message to which I
was replying said, "BTW, a LAN address will start with 10.xxx.xxx.xxx."
This is an untrue statement in the vast majority of cases.

If you want to determine if someone else is connected, using their fixed IP
address, PING is the fairly standard method, but requires that the device be
responsive to the ICMP packets sent to it. If the reason you want to know
is to decide if you should connect to the other system, attempting the
connection is a pretty reliable way!

Paul T.
 
Use connection manager.

Connection manager will connect to the required network using any available
path and then let you know if the connection was made.

There is a good implementation of a connection manager wrapper on
opennetcf.com.

Martin.
 
Back
Top