简体   繁体   English

Android:将TCP连接从3G传输到WiFi

[英]Android: Transferring TCP connection from 3G to WiFi

I'm creating an application for Android that uses TCP to download files. 我正在创建一个使用TCP下载文件的Android应用程序。 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. 有些设备甚至具有在找到合适的热点时立即激活WiFi的功能,并禁用现有的移动数据连接。

How to keep a TCP-based connection alive while switching networks? 如何在切换网络时保持基于TCP的连接存活? 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. 我对网络知之甚少,但我知道TCP连接固定在IP上,Android手机上的移动网络和wifi接口有不同的IP。 So, if the IP changes, is the existing connection complete unreachable by the other network? 那么,如果IP发生变化,现有连接是否完全无法通过其他网络连接?

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. 如果一个块由于连接更改而超时,则使用当前可用的连接类型再次启动块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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