I am not sure of how many folks have tried to do something like what I have crossed recently…

What if you have to manage to connect 2 hosts, one in your local network and other on a remote network?
Well.. it is kind of odd scenario but It can happen… You will have to use your Wifi to connect to your local host and GPRS to connect to remote host.

However there is a problem: when developing app it is thought that OS can manage both connections and address each connection to right network.

Unfortunately it is nothing like that!!!

I have crossed this issue and it cost me some sleep, but I figured it out…

Each connection (nic) has one metric assigned to it; lesser the metric bigger the priority. this metric is evaluated on nic’s speed – so you calculate something like craddle metric < wifi < GPRS.

What you see is that wifi will have a lesser metric and therefore a bigger priority; when you try to reach remote host it won’t since your wifi connection overrides your gprs.

This is Windows mobile 6 behavior and not expected to me…
Having this known is time to work on a solution… I am not the first facing this and will not the last, so let us bring a solution to next guy.

There is something like a routing table also on windows mobile. What we can manage to do is first of all check if our device has gprs connected. If so, then we must add an entry on routing table that tells that when trying to reach that “XXXX” address it should go on that specific nic and not by metric.

This may seem hard to do… some complex C# as you may think.. or not! :)

I have managed to manufacture a solution based on OpenNetCommunity library.

There are some things you should manage:  your nics and your routes.

I do believe that it can be bet understood with an example.
I will leave you with my lab that exemplifies a solutions with OpenNet.

Lab: TestingWifiAndGPRSConnection

For this lab I hard coded mask Address and Ip Address, but you can have it on a file of settings or in a textBox, whatever….

Some details:
I had to configure Internet connection to GPRS and Local Connection to Ethernet; also had an exception relative to my service since it was http on local network.

Final detail was that I defined my IpFowarding as Route.Intermediate.

I don’t know if it was all needed but this was how I finally achieved my goal!

Be happy now!