boost-asio

serial port configuration using boost ASIO

一个人想着一个人 提交于 2020-01-15 14:23:34
问题 I am configuring serial port using boost asio. but why below code is giving error? If I comment set_option it works fine. below code gives error serial_config.cpp:13: error: expected unqualified-id before numeric constant In file included from /home/chirag/boost_install/include/boost/asio/serial_port_service.hpp:25, from /home/chirag/boost_install/include/boost/asio/basic_serial_port.hpp:30, from /home/chirag/boost_install/include/boost/asio.hpp:25, from serial_config.cpp:1: /home/chirag

Use of Boost.Log and Boost.ASIO causes a crash

陌路散爱 提交于 2020-01-15 04:38:09
问题 I am running into an issue where the use of Boost.Log in an app causes a crash or a hang when the app loads a shared library that uses Boost.ASIO! Any insights would be appreciated; a full cmake-buildable example is below. If the declaration of the global logger object in main.cpp is uncommented the program will either seg-fault immediately or the resolve() call will do nothing. If left commented out then the program works. I'm using Boost 1.55, g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

boost::bind composition inside io_service::post function

五迷三道 提交于 2020-01-15 03:58:41
问题 Given the following class class task_counter { public: task_counter(short, boost::asio::io_service&); ~task_counter(void); template<typename CompletionHandler> void exec_task(CompletionHandler handler) { grant_access(); io_.post(boost::bind(&task_counter::exec_and_decrease_counter<CompletionHandler>, this, handler)); } template<typename CompletionHandler> void exec_and_decrease_counter(CompletionHandler handler) { handler(); decrease_counter(); } private: .... } Method exec_task is called by

How to cast `std::chrono::milliseconds` to `boost::posix_time::milliseconds`

天涯浪子 提交于 2020-01-14 19:21:06
问题 I am using a boost::asio::deadline_timer like so to set some timeout before an async_read operation on a tcp socket . I am using boost 1.61 . long time_out_millis = 2000; boost::asio::deadline_timer theTimer(theSocket.get_io_service(), boost::posix_time::milliseconds(time_out_millis)); Problem: Other parts of my code use std::chrono::milliseconds . I want use std::chrono instead of the "long time_out_millis" & if possible use std::chrono::milliseconds instead of boost::posix_time:

What is the performance difference between strand.post and strand.wrap?

丶灬走出姿态 提交于 2020-01-13 19:50:23
问题 What is the performance difference between strand::post() and strand::wrap() ? And what's the story about race condition when use strand::wrap( )? 回答1: Just for clarification, strand::wrap only creates a handler, neither the provided handler nor returned handler are dispatched or posted to the io_service . If the result from strand::wrap is executed, then performance differences from overhead is negligible. However, a perceived performance difference could occur as the result of the wrapped

Can't get segmentation fault exit code from boost child process

一世执手 提交于 2020-01-13 05:45:24
问题 I am trying to get the exit code of a child process (using boost::process and boost::asio) when that child process is killed due to a segmentation violation or divide be zero or any other kill signal. The exit code and error code always return with 0 and success. I am running this on CentOS 7 using g++ 4.8.5 and boost 1.66 If I run the same code with a child process that simply returns a non-zero exit code it successfully returns that exit code. #include <iostream> #include <boost/process.hpp

Boost asio send and receive messages

百般思念 提交于 2020-01-13 03:44:08
问题 I'm trying to send and receive messages from a client and server using TCP. I'm trying it with threading, and I don't know how to do this at all. I can connect to the server just fine, but I need to be able to send and receive messages from both places on demand. I've been searching for hours and have come up empty, as all of the results on Google are overcomplicated and cluttering. struct Client { boost::asio::ip::tcp::socket socket; Client(const char* host = HOST, const char* port = PORT) :

HTTP Client Request Response with pion-net c++

怎甘沉沦 提交于 2020-01-12 10:30:09
问题 I want to create a simple HTTPClient with pion-net (Pion-net leverages boost::asio.). Boot Version 1.49 Pion-net Version 4.11 My client should just be a able to: send a HTTP Request (this is working) receive the HTTP Response (not working) asynchronous code is not a must, synchronous would be ok This is what I got: #include <iostream> #include "boost/asio.hpp" #include "boost/thread.hpp" #include "pion/net/HTTPRequestWriter.hpp" #include "pion/net/HTTPResponseReader.hpp" void

boost::asio internal threads

人走茶凉 提交于 2020-01-12 09:16:03
问题 When using boost::asio for some asynchronous TCP communication I noticed it starts a lot of (3-4) internal threads. Reading in the documentation, it says "The implementation of this library for a particular platform may make use of one or more internal threads to emulate asynchronicity" Now my lib has very strict requirements to not start any extra threads (except one that is supplied by the client and which now starts io_service::run() ). Is there any way to stop boost::asio from creating

boost::asio internal threads

强颜欢笑 提交于 2020-01-12 09:14:04
问题 When using boost::asio for some asynchronous TCP communication I noticed it starts a lot of (3-4) internal threads. Reading in the documentation, it says "The implementation of this library for a particular platform may make use of one or more internal threads to emulate asynchronicity" Now my lib has very strict requirements to not start any extra threads (except one that is supplied by the client and which now starts io_service::run() ). Is there any way to stop boost::asio from creating