On Friday, I needed a way for a Windows Mobile device connected via USB cable to Active-Sync/Windows Mobile Device Centre (WMDC) to talk back to the local web-server running on the host PC.
I’d never done this before, it suddenly struck me, what IP address do I need to talk to? More importantly how could this IP address be obtained on the connecting device.
Here’s the solution -
System.Net.IPAddress ip = Dns.GetHostEntry("ppp_peer").AddressList[0];
This will always give you a reference to the attached machine.