I have the following sequence:
socket = await Socket.connect(host, port, timeout: const Duration(seconds: 5));
socket.add(data);
await socket.flush();
await socket.close();
socket.destroy();
I have a mostly reproducible scenario when repeated runs of this same code (especially if the app was started right after killing it from the Recent apps list) don’t actually send out the data. Every step is finished without error and on time, logs attest to that, there’s no exception anywhere. Data intended to send is buffered somewhere in the system and it will only be actually sent out when I start the app again and kill it from the Recent apps. As soon as the app is forcibly removed, the previously accumulated data gets sent. No logcat message that reveals anything (apart from a “W/System: A resource failed to call release” that I’m not sure is related, StrictMode
is on, still there’s no explanation for it in the log).
Could this be a problem with a specific hardware? The code in question is from an app available in the store, I didn’t have user reports that describe the same behavior but I can see it on my test phone.