Current IP is 127.0

P

Pascal Berger

I use the following code to get the IP address of a pocket pc device:

string HostName = Dns.GetHostName();
IPHostEntry thisHost = Dns.GetHostByName(HostName);
string thisIpAddr = thisHost.AddressList[0].ToString();

Unfortunatly sometimes this reports 127.0.0.1, when connected with the
craddle.

VxUtil also reports 127.0.0.1 for the curent IP, but also an adapter
(ppp1 or USB Cable, depending on Pocket PC version) with an valid IP
adress. Other applications, like PocketIE are also working fine.

Thanks in advance
Pascal
 
P

Paul G. Tobey [eMVP]

There can be more than one IP address assigned to a device. I'm surprised
that you're getting a loopback address from that sequence of calls, if you
have a valid connection, but I don't feel like that sequence is what I'd
use. Have you looked at OpenNETCF? You can get a list of adapters and the
IP address for each, so you could iterate through the list of adapters,
ignoring loopback, etc...

Paul T.
 
P

Pascal Berger

Paul said:
There can be more than one IP address assigned to a device. I'm surprised
that you're getting a loopback address from that sequence of calls, if you
have a valid connection, but I don't feel like that sequence is what I'd
use.
Sure there can be more adapters, but in this case there's only one
adapter, so the current IP shouldn't be the loopback device.
Have you looked at OpenNETCF? You can get a list of adapters and the
IP address for each, so you could iterate through the list of adapters,
ignoring loopback, etc...
Yes I've tried with Networking.GetAdapters(), but this returns no items...

Thanks
Pascal
 
P

Paul G. Tobey [eMVP]

There is always a loopback adapter so you either have one or more adapters.
As I said, I'm surprised that you get the loopback address, if you have a
valid network connection, but I wouldn't recommend your method of figuring
out what *the* IP address is, because it can easily be wrong.

If Networking.GetAdapters returns a list with zero entries, you don't have a
valid real network adapter, as far as Windows CE is concerned, you don't
have the IP Helper API on your device, or something else is very strange.
This *does* explain why you are getting the result you are, however.

Tell us more about the target device (OS, version, manufacturer, network
adapter, etc.)

Paul T.
 
P

Pascal Berger

Paul said:
There is always a loopback adapter so you either have one or more adapters.
As I said, I'm surprised that you get the loopback address, if you have a
valid network connection, but I wouldn't recommend your method of figuring
out what *the* IP address is, because it can easily be wrong.
Any other idea? This is some code I got from MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/NetworkComponent.asp
If Networking.GetAdapters returns a list with zero entries, you don't have a
valid real network adapter, as far as Windows CE is concerned, you don't
have the IP Helper API on your device, or something else is very strange.
vxUtil reports a network adapter (but also 127.0.0.1 for the current IP).
This *does* explain why you are getting the result you are, however.
But I *have* a (and just one) valid network adapter. Else e.g. PocketIE
wouldn't work too.
Tell us more about the target device (OS, version, manufacturer, network
adapter, etc.)
I've had the error for sure with an IPAQ H3800 (PPC 2002) and an IPAQ
5555 (PPC 2003).
Both time using the craddle. The H3800 has no additional network
adapters, the Bluetooth and Wireless adapter of the 5555 was disabled.

I don't think it has something to do with the device, because on both
devices it generally works. Also after an hard reset everything is OK again.

Thanks
Pascal
 
P

Paul G. Tobey [eMVP]

I've fixed a bug in the Adapter.cs file in OpenNETCF. You might try using
that one more time and see if you get something better. I don't think that
this bug should affect you, but I'd feel more confident that we're really
testing things correctly. In my case, with a *serial* ActiveSync connection
and two network adapters connected, everything is correctly enumerated and
the IP address for the ActiveSync connect appears correctly.

If that doesn't work, I can't think of anything else to try...

Paul T.
 
P

Pascal Berger

Paul said:
I've fixed a bug in the Adapter.cs file in OpenNETCF. You might try using
that one more time and see if you get something better. I don't think that
this bug should affect you, but I'd feel more confident that we're really
testing things correctly. In my case, with a *serial* ActiveSync connection
and two network adapters connected, everything is correctly enumerated and
the IP address for the ActiveSync connect appears correctly.
I've got the souce vault.netcf.tv, added the OpenNETCF assemblies to my
solution, rebuilded everything.

Networking.GetAdapters() still returns an empty list (IPAQ H3800; PPC
2002; Connect with Craddle/USB)

Thanks
Pascal
 
P

Paul G. Tobey [eMVP]

Sounds like HP is doing something that I can't duplicate here. I'll see if
I can think of anything else...

Paul T.
 

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

Top