Question

Assume that, I have a TCP connection that doing heavy data transmitting on my 3G network; and I walked home, Android switch to my home Wifi automatically. Now what happen to the existing connection? is it simply disconnect? or it will keep going, only new connections will use wifi?

In addition, what if I walk away from home, wifi lost signal and switch to 3g? It should be safe to guess the connection is dropped. For my application, do I need to handle the reconnection or there is a auto fall back solution?

Thanks in advance.

Hongbo

Was it helpful?

Solution

The connection will drop because your device will appear at a different IP address, which is how TCP packets find their way.

There is no fallback unless you code it up, which you should do anyway if your app spends a lot of time on 3G. It's quite OK for desktop applications to go "D'oh!" when your Cable or DSL has the occasional hiccup, but 3G connections go down routinely.

OTHER TIPS

The same thing would happen as if you plugged out a laptop from one network and plugged in another. Connections would drop. Mobile apps are far more likely to encounter dropped / dead connections so they should be coded accordingly. For example apps could register for status changes via android.net.ConnectivityManager. In some cases it may be necessary for apps to do an integrity check on anything they download just so they don't start trying to render a broken file. In other cases it would be bad form to download certain kinds of data (e.g. large files) if the connection is through 3G.

Nothing. You should enumerate all current IP addresses and bind to each of them on different sockets. And subscribe to Reachability (a sort of for Android) notifications when network state / IP addresses changes. Code should work in Android too. See my multipath example in this gist: https://gist.github.com/avesus/fdb465b60a4f5204845c

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top