Boost logo

Boost :

From: JH (jupiter.hce_at_[hidden])
Date: 2019-06-25 08:14:43


Hi Gavin,

I should clarify it is a client socket connection.

On 6/25/19, Gavin Lambert via Boost <boost_at_[hidden]> wrote:
> On 25/06/2019 17:43, JH wrote:
>> I have an application using ASIO TCP/IP SSL socket connection in an
>> embedded device, the device has two network interfaces, when one is
>> down, another network interface takes over, which requires application
>> TCP SSL socket connection to be established binding to a new network
>> interface. What will be an appropriate implementation to switch
>> application TCP connection from one to another interface?
>
> The simplest option is to not bind to a network interface in the first
> place. Provided that only at most one is up at a given moment, the OS
> will take care of routing the data appropriately.

Did you mean to remove bind interface in client code, right? Sorry
where I should to remove the bind to a network interface? Here is my
client connection code:

void AsyncClientSslConnection::InitialConnection(void) {
    boost::asio::ip::tcp::resolver::query query(this->mHost, this->mPort);
    boost::asio::ip::tcp::resolver::iterator iterator =
this->mResolver.resolve(query);
    this->mSocket.set_verify_mode(boost::asio::ssl::verify_peer);
    this->mSocket.set_verify_callback(boost::bind(&AsyncClientSslConnection::VerifyCertificate,
this, _1, _2));
    boost::asio::async_connect(this->mSocket.lowest_layer(), iterator,
boost::bind(&AsyncClientSslConnection::HandleConnect, this,
boost::asio::placeholders::error));
}

At the moment, when one interface is down, the client TCP socket keeps
sending the data to server, but the remote server could no longer
receive it.

> You're never allowed to have both interfaces up at the same time to the
> same network, unless the OS itself has special routing to handle
> failover -- in which case again, you don't need anything fancy in the
> application.

You right, there would be only one interface has IP address, the OS is
Linux Ubuntu and Yocto OS, I guess both should be able to handle
failover, the key is where the binding statement?

Thank you very much.

- j


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk