boost-asio

need to call ssl::stream::shutdown when closing boost asio ssl socket?

孤者浪人 提交于 2019-12-06 04:47:12
问题 My code is as follows: declaration: boost::asio::ssl::stream<boost::asio::ip::tcp::socket> m_remote_socket; m_remote_socket.shutdown(ec); if (ec) { cdbug<<"id: "<<m_id<<", error when ssl shutdown: " <<boost::system::system_category().message(ec.value()).c_str(); } m_remote_socket.lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); if (ec) { cdbug<<"id: "<<m_id<<", error when tcp shutdown: "<<boost::system::system_category().message(ec.value()).c_str(); } Each time I call

Boost Asio - Server doesn't receive message

蹲街弑〆低调 提交于 2019-12-06 04:18:19
I'm developing a 3d (first/third person) game and I'm trying to make it multiplayer using TCP sockets. I'm using the boost asio library for this, and I'm in a little over my head. I've played with the tutorials and examples a bit on the boost asio doc page and they compiled/ran/worked just fine, I'm just a little confused as to how everything works. Right now I'm just trying to make the server accept messages from the client, and print the message after receiving it. When I execute the code below (it compiles/links/runs fine), nothing happens. More specifically, the client appears to

boost asio with ECDSA certificate issue

ε祈祈猫儿з 提交于 2019-12-06 03:20:44
I am implementing SSL server using boost::asio. The context initialization is shown in below code boost::asio::ssl::context_base::method SSL_version = static_cast<boost::asio::ssl::context_base::method>(param_values[ID_PROTOCOL_VERSION].int32_value); // load certificate files boost::shared_ptr<boost::asio::ssl::context> context_ = boost::shared_ptr<boost::asio::ssl::context>( new boost::asio::ssl::context(SSL_version)); p_ctx = boost::static_pointer_cast<void>(context_); context_->set_options(boost::asio::ssl::context::default_workarounds); context_->use_certificate_chain_file(cert_chain_file)

boost thread pool

折月煮酒 提交于 2019-12-06 02:51:52
I need a threadpool for my application, and I'd like to rely on standard (C++11 or boost) stuff as much as possible. I realize there is an unofficial(!) boost thread pool class, which basically solves what I need, however I'd rather avoid it because it is not in the boost library itself -- why is it still not in the core library after so many years? In some posts on this page and elsewhere, people suggested using boost::asio to achieve a threadpool like behavior. At first sight, that looked like what I wanted to do, however I found out that all implementations I have seen have no means to join

boost::asio - Clarification on binding to a specific network interface

岁酱吖の 提交于 2019-12-06 02:32:45
问题 I've been searching the net for answers but I can't seem to find a complete answer. Scenario: I have a client API and a server. An application uses the client API to talk to the server. Both TCP and UDP are used to communicate between the client API and the server. All of this has been written using ASIO. The client API connects to the server via TCP, then sends commands via TCP and receives responses via TCP. The client API also listens to a UDP address where it receives real-time data

Boost.Asio segfault, no idea why

我们两清 提交于 2019-12-06 02:18:06
问题 This is a SSCCE from my Boost.Asio project based on the examples. It took me about an hour to track the bug down to this: #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/shared_ptr.hpp> class Connection { public: Connection(boost::asio::io_service& io_service) : socket(io_service) {} private: boost::asio::ip::tcp::socket socket; }; class Server { public: Server() : signal_monitor(io_service) { signal_monitor.add(SIGINT); signal_monitor.add(SIGTERM); signal_monitor.async

Better boost asio deadline_timer example

天涯浪子 提交于 2019-12-06 01:39:12
问题 I'm after a better example of the boost::asio::deadline_timer The examples given will always time out and call the close method. I tried calling cancel() on a timer but that causes the function passed into async_wait to be called immediately. Whats the correct way working with timers in a async tcp client? 回答1: You mention that calling cancel() on a timer causes the function passed to async_wait to be called immediately. This is the expected behavior but remember that you can check the error

boost::asio, thread pools and thread monitoring

試著忘記壹切 提交于 2019-12-05 23:38:14
问题 I've implemented a thread pool using boost::asio , and some number boost::thread objects calling boost::asio::io_service::run() . However, a requirement that I've been given is to have a way to monitor all threads for "health". My intent is to make a simple sentinel object that can be passed through the thread pool -- if it makes it through, then we can assume that the thread is still processing work. However, given my implementation, I'm not sure how (if) I can monitor all the threads in the

Boost.Asio without Boost.System

喜夏-厌秋 提交于 2019-12-05 23:33:46
On the Boost System page it is stated that: The Boost System Library is part of the C++11 Standard Library. But a number of Boost libraries, such as Asio, depend on Boost System. Is it possible to use the C++11 std stuff instead of Boost System to work with Asio? AFAIR you can configure Boost System to be header-only Source: http://www.boost.org/doc/libs/1_66_0/libs/system/doc/reference.html Other than that, you might simply use Non-Boost Asio 来源: https://stackoverflow.com/questions/49418493/boost-asio-without-boost-system

What is boost::asio::ssl::context::load_verify_file and how to work with it?

回眸只為那壹抹淺笑 提交于 2019-12-05 22:55:26
问题 Theare is a wary small amount of boost::asio::ssl small C++ educational codes base online. Even less on boost::asio::ssl::context::load_verify_file So I found one from here code with minimal modifications - compiles and runs with boost 1.47.0: #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> #include <boost/bind.hpp> #include <iostream> #include <istream> #include <ostream> #include <string> class client { public: client(boost::asio::io_service& io_service, boost::asio::ssl::context&