[asio] reconnect without close the socket, is it possible?

Hi, I want to know if the connection is broken up at some point, can I reconnect without shutdown-close the socket. On Windows, I keep getting already_connected error when reconnecting but still fails to do other async read/write... Also, any way to test if the socket is connected? Thanks.

2013/7/26 Bjorn Reese
On 07/25/2013 06:26 PM, TONGARI J wrote:
Also, any way to test if the socket is connected?
If is_open() does not work, you could try remote_endpoint().
Neither of them helps :( Even though not connected, remote_endpoint(ec) returns the intended endpoint without error...

On 07/28/2013 02:42 PM, TONGARI J wrote:
Neither of them helps :(
Even though not connected, remote_endpoint(ec) returns the intended endpoint without error...
Sounds like an error in Boost.Asio then. On Linux it just calls getpeername() so we always get the right result, whereas on Windows it appears to cache the remote endpoint, and you may have encountered a situation where the cache is out of sync with reality. Maybe you should create a ticket (or post to the asio mailing-list or whatever one does to get the attention of the Asio author.)
participants (2)
-
Bjorn Reese
-
TONGARI J