27 Jul
2008
27 Jul
'08
1:56 p.m.
I am having a little trouble getting my boost::ASIO TCP client to actually re-attempt a connected if the first attempt failed. With my server offline, the call to async_connect correctly times out. When I try the async_connect call a second time, it doesn't time out.
It's unclear from your code where/how you try to re-connect. IIUC, your HandleConnect() function doesn't reconnect, but just iterates over the endpoints that you were given by the address resolver... So if you've got 1 endpoint, then the 1st time you get into HandleConnect with some error - you call DoClose(), and if the io_service has no more work, it just ends (with the whole thread).