I have an ASIO socket server. I need to close the socket and then listen to
the socket again if client disconnected from server.
<...>
asio_acceptorPtr->close(error_closing);
asio_socketPtr->shutdown(tcp::socket::shutdown_both, error_closing);
asio_socketPtr->close(error_closing);
in the process reopen the socket, I did the following in order:
asio_socketPtr->open(protocol, error_connecting);
asio_acceptorPtr->open(protocol, error_connecting);
Why do you need to close the acceptor? Can't you continue accepting incoming connections with the same acceptor?
Why do you need to close the socket? You said that the client already disconnected, so your server socket is closed anyway.
Anyway, if your asio_socketPtr is a server socket that accepts an incoming connection, then you have to pass it to the acceptor's async_accept/accept member functions - the acceptor will "open" the socket.