Our apk will connect to a server automatically when the user switches wifi network. It will invoke gethostbyname to find the server's ip first and then connect to the ip. All these code is written in C++.Everything works priori to Android 4.0. But in Android 4.0, gethostbyname returns the original ip for the server after switching the wifi network. So the apk's connection timeouts. The only possible solution is to restart the apk. But the java code InetAddress.getAllByName works ok. So what's wrong with Android 4.0's gethostbyname in C?
Asked
Active
Viewed 763 times
0
-
Can you clarify what you mean by "the original ip for the server after switching the wifi network"? Are you using split DNS? – David Schwartz May 28 '12 at 06:22
-
The server address shouldn't change, should it? Or are you changing network for the server and not the phone? – Some programmer dude May 28 '12 at 06:24
-
After switching wifi network, the android device is assigned a different DNS server , the server which the apk wants to connect should have a different ip. – crybird May 28 '12 at 06:35
-
Do the server have several networks and multiple ip-addresses? If not, then you _should_ get the same address. – Some programmer dude May 28 '12 at 06:49
-
The server has a different ip. Restart the apk after switching the wifi network , the apk will see the second ip for the server – crybird May 28 '12 at 07:17