-2

I want to use boost asio to create a tcp client, and async_connect to a server every ten second until successful. Do you give me an example? Thanks.

lihao
  • 49
  • 4

1 Answers1

0

You can use boost::asio::deadline_timer to measure time until the next connection attempt.

  1. Call async_connect, pass handler, e.g. handle_connect
  2. If handle_connect states that any error has occured, use a deadline_timer to measure 10 seconds before the next connection attempt.