In my project, there is a 2 sided connection based on a TCP protocol. One waits for information (PC), and the other one sends it (phone).
I have noticed that if I change the phone's WiFi connection (IP address) while a connection between the devices is alive, the PC side has no idea that the phone has disconnected already.
I think it is called a half opened connection, and as far as I understood, the PC side has to send some empty message in order to detect the disconnection, yet I can't manage to do that.
I tried using socket.send("".encode("utf-8"))
, but it didn't seem to invoke any error.
Is the connection still alive, even if one side is disconnected? And how can the PC detect this issue with Python?
Also, what happens if I send informationg from a socket (in a different thread), while the recv
command is running?