开发者

How to know the status of a SSL socket in Boost asio

开发者 https://www.devze.com 2023-02-24 04:02 出处:网络
In normal connections, asuming a socket: boost::asio::ip::tcp::socketsocket_; it\'s possible ask the socket status with:

In normal connections, asuming a socket:

boost::asio::ip::tcp::socket  socket_;

it's possible ask the socket status with:

if (socket_.is_open()) { ... }

But instead, in secure connections, asuming a soc开发者_开发知识库ket:

boost::asio::ssl::stream<boost::asio::ip::tcp::socket> socket_;

There is not an is_open() method for the socket_ object, so the question:

Is there a similar way to know the socket status?


boost::asio::ssl::stream<boost::asio::ip::tcp::socket> socket_;
if ( socket_.lowest_layer().is_open() ) {
    // do something great
}

see the documentation for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消