简体   繁体   中英

Android: Transferring TCP connection from 3G to WiFi

I'm creating an application for Android that uses TCP to download files. It's done, and working great, but I'm having a problem with people switching from a network to another while downloading files, because the download halts and eventually times out. Some devices even have a function that activates WiFi immediately when a suitable hotspot is found and disables the existing mobile data connection.

How to keep a TCP-based connection alive while switching networks? Is it even possible? I don't know much about networking, but I know that TCP connections are pinned to IPs and that mobile network and wifi interfaces on Android phones have different IPs. So, if the IP changes, is the existing connection complete unreachable by the other network?

Download the file in smaller chunks rather than as one complete download. If one chunk times out because the connection changes, you initiate the chunk again using the currently available connection type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM