Added a timer to check if the TCP connection is still alive.
Needs testing.