Post #2768158
2023-12-12 15:31 UTC
@dalias@hachyderm.io Essentially, Android apps are not native Linux programs. They run on top of a virtual machine that abstracts away the operating system capabilities to a degree deemed necessary by Google.
Specifically, when your app is sent to sleep by the VM because of inactivity, your socket will time out. Android is a Linux in name only and the abstractions put in place by Google do not support (or rather: not allow) what you suggest.
Replies (1)
-
@dalias@hachyderm.io 2023-12-12 16:27
@ck@chaos.social That's not true at all. For example see the ConnectBot ssh client, which keeps ssh connections open in the background just fine. There is no "VM", but there is nasty auto-killing which you either need to suppress via an explicit backgrounding action (which shows a persistent notification unless the user opts to hide it) or you need to tell the user to disable "battery optimization" (actually pessimization) for your app and deal with the fairly rare remaining bg kills.