Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 using tcp keepalive.

share|improve this question
First, please clarify your question. Are you asking about the keepalived software for load balancing and high availability, or the TCP keepalive mechanism for holding open idle TCP connections (which you provided a link to)? These are two completely different things. – Michael Hampton Sep 24 '12 at 14:25
TCP keepalived. – Avihai Marchiano Sep 24 '12 at 14:38
I'm not sure you understood my comment. The two are completely different things, and you've linked to a howto that doesn't address keepalived at all. – Michael Hampton Sep 24 '12 at 14:39
up vote 0 down vote accepted

You seem to be confusing the TCP keepalive mechanism with a load balancing daemon called keepalived. The two have nothing to do with each other. And if you're trying to detect connection loss or problems between two programs, both of which you've written, you don't want either mechanism.

If you want to detect a bad connection between two programs when you've written both of them, just build dead connection detection into the code. TCP guarantees that a side that is sending will detect a dead connection. So the simplest solution is to ensure that both sides send periodically. Another solution is to ensure one side sends periodically and the other side declares the connection dead if it does not receive that periodic data.

share|improve this answer
I try to implmemt hearbeat between 2 process by using tcp keep alived. this was the advice in this post -… – Avihai Marchiano Sep 24 '12 at 18:13
That suggestion was to use keepalive, not keepalived. Unfortunately, that's a terrible answer though. TCP keepalives should not be used for anything new, they're a compatibility workaround for legacy implementations. – David Schwartz Sep 24 '12 at 18:18
Here's a better answer to that question. – David Schwartz Sep 24 '12 at 18:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.