Boost logo

Boost :

From: JH (jupiter.hce_at_[hidden])
Date: 2019-06-29 00:35:24

Sorry for keeping posting questions about ASIO TCP socket reconnection
regarding to network interface changes, I am very much stuck at the

As I described in other emails, when one network interface WiFi
failed, the network interface Ethernet takes over, the client
application using boost ASIO TCP socket cannot detect the broken of
WiFi, it continually sent messages to the remote server via the broken
WiFi interface without triggering errors but obviously the server
could not receive messages any more.

So my solution is prior to send message, it ping to via the
network interface WiFi, if it failed, it called the SetConnection
again to close the socket binding to WiFi interface and to start
reconnection to bind to Ethernet interface:

void SetConnection(void) {
    if (this->mSocket.lowest_layer().is_open()) {
        std::cout << "Set connection close socket" << std::endl;
    boost::asio::ip::tcp::resolver resolver(this->mIoService);
    boost::asio::ip::tcp::resolver::query query(this->mHost, this->mPort);
    this->mIterator = resolver.resolve(query);
this, _1, _2));
this->mIterator, boost::bind(&client::handle_connect, this,

But it did not work, the error: handle_connect connect failed: Network
is unreachable

What I am missing here? How can I make the TCP socket reconnection?

Thank you.

Kind regards,

- jupiter

Boost list run by bdawes at, gregod at, cpdaniel at, john at