Re: TCPIP_TCP_IsConnected returns true even after network cable is unplugged
The behavior is actually correct. Hopefully this explanation won't be too confusing, because this is a complex topic. The complexity occurs in the TCP state machine. TCP sits on top of IP which sits on top of the Ethernet MAC which sits on top of the Ethernet Physical Layer.
The TCP layer has an industry standard statemachine. It goes from closed -> Listen -> syn send/syn received -> established -> close wait/fin wait. The TCPIP_TCP_isConnected function will return true if it is in the established state.
With this in mind, the function will return true unless something kicks the tcp connection out of the established state. A packet timeout for instance. Lower layers (IP) can reset the connection. But the IP layer won't tell the upper layer (TCP) unless it's IP address changes.
With you unplugging the cable, the physical layer is down, but there is nothing to tell the IP layer that its address has changed, and it hasn't, so it doesn't signal the TCP layer that it has changed so the TCP connection state doesn't change.
On older windows machines (I think 95, 98, ME) when you disconnected the Ethernet cable it would immediately kill all network connections. On Linux and newer Windows versions it won't kill the connections right away, allowing the physical connection to be re-established.
Its basically a choice between killing the connections right away, or hoping that the outage at the lower layer re-establishes and you can continue your application without having to start from scratch.