I'm trying to implement in capnproto something like boost's connect function which blocks and retries until the server is up, or basic_socket::async_connect that lets me implement a callback with which to try connecting once more.
For example, running this code:
auto ioContext = kj::setupAsyncIo();
auto address = ioContext.provider->getNetwork()
.parseAddress("localhost:7500").wait(ioContext.waitScope);
auto connection = address->connect().wait(ioContext.waitScope);
Would obviously throw an exception if the server is down.
So my questions are:
- Is there a way to register a callback that will handle connection/failure to connect?
- Is there a built in mechanism in capnproto that already enables automatic reconnection?