Bilcan 0 Posted August 11 Switching from wi-fi to mobile data in an Android app raises a disconnect, but on Windows, the same application does nothing when I switch-off wifi, which is what I want exactly. So am I missing something on the Android side? Delphi 12 Indy Share this post Link to post
Remy Lebeau 1396 Posted August 11 No. The connection has to be disconnected and reconnected, it can't be moved from one network to another. Android is doing the right thing. https://android.stackexchange.com/questions/83830/how-can-android-keep-a-tcp-connection-alive-when-changing-network-provider I would question why Windows is not doing the same thing, as it should be. Maybe your code is just not doing anything that triggers a disconnect during a network change? On both platforms, you might consider having your app register with the OS to receive network change notifications. 1 Share this post Link to post
Bilcan 0 Posted August 11 Quote I would question why Windows is not doing the same thing, as it should be. Maybe your code is just not doing anything that triggers a disconnect during a network change? On both platforms, you might consider having your app register with the OS to receive network change notifications. I just turn off the wifi, wait for a while, then turn it on again, so maybe this is not a network change for the Windows OS. Quote No. The connection has to be disconnected and reconnected, it can't be moved from one network to another. Android is doing the right thing. Thank you for the clarification. @Remy Lebeau Share this post Link to post
Remy Lebeau 1396 Posted August 11 23 minutes ago, Bilcan said: I just turn off the wifi, wait for a while, then turn it on again, so maybe this is not a network change for the Windows OS. Quite possibly. Keep in mind that TCP is resilient to temporary network outages, so as long as the WiFi maintains the same IP when it comes back on, previous TCP connections may be recoverable by the OS if it hasn't invalidated them yet. On the other hand, if your code is not reading/writing data with the connection during the time that the WiFi is turned off, then it makes sense that you won't see a disconnect. It can take time for a lost connection to be detected. If the OS's internal timeout is not to your liking, you might consider enabling TCP keep-alives on the connection. 1 Share this post Link to post
Bilcan 0 Posted August 11 Thank you for the answers, I understand the issue better now. Share this post Link to post