In "https://github.com/sachinsaini4278/Socket-Programming-using-boost-asio/blob/master/SynClientHeartbeat.cpp#L32": sleepThread(sock); //call recursively Wouldn't this let the used stack grow "forever"...? Imagine a server with an heartbeat every 1s or 500ms, letting the server run 24/7? Could you imagine to e.g. use a (boost-)timer or a (boost-)signal instead?