What will happen to existing connections when switch between 3g/wifi
Asked Answered
G

3

18

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

Gautama answered 18/8, 2010 at 12:38 Comment(1)
Interesting question. that's worth a +1 for me ;)Yuonneyup
U
9

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.

Urolith answered 18/8, 2010 at 12:55 Comment(0)
M
1

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.

Moyra answered 18/8, 2010 at 14:10 Comment(0)
T
0

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

Turki answered 21/4, 2015 at 22:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.