TCP keepalive how does it work

view story

http://serverfault.com – I run on Ubuntu and i want to use TCP keepalive in order to implement hearbeat between master-slave.both servers are my impl (c++). I read this overview and did some google. i didnt understand what TCP keepalive send and i do know if connection is no longer valid when use in TCP keepalive ?. Do i need to check the revived content? The target is to have hearbeat between master-slave , so if one failed the other will be the master. in this post the advice is to implement hearbeat with tcp keepalive mechanism, so this is the reason that i am asking how i identify the broken connection when usi (HowTos)