boost-asio

Boost Asio UDP retrieve last packet in socket buffer

元气小坏坏 提交于 2019-12-24 23:53:31
问题 I have been messing around Boost Asio for some days now but I got stuck with this weird behavior. Please let me explain. Computer A is sending continuos udp packets every 500 ms to computer B, computer B desires to read A's packets with it own velocity but only wants A's last packet, obviously the most updated one. It has come to my attention that when I do a: mSocket.receive_from(boost::asio::buffer(mBuffer), mEndPoint); I can get OLD packets that were not processed (almost everytime). Does

Boost asio serial port initially sending bad data

浪尽此生 提交于 2019-12-24 20:13:19
问题 I am attempting to use boost asio for serial communication. I am currently working in Windows, but will eventually be moving the code into Linux. When ever I restart my computer data sent from the program is not what it should be (for example I send a null followed by a carriage return and get "00111111 10000011" in binary) and it is not consistent (multiple nulls yield different binary). However, as soon as I use any other program to send any data to the serial port and run the program again

Serialize io_service::post() execution with io_service::run() called only in a single thread

萝らか妹 提交于 2019-12-24 17:23:43
问题 If I have io_service::run() running only in a single thread , are io_service::post() calls executed in the same order I request them to be executed, or they can be executed in arbitrary order and I still need to use strand for forcing serialized execution? 回答1: The question has been treated before, e.g. Does boost::asio::io_service preserve the order of handlers?? Documentation: Oreder Of Handler Invocations It clearly spells out if any of the following conditions are true: s.post(a) happens

Serialize io_service::post() execution with io_service::run() called only in a single thread

时光怂恿深爱的人放手 提交于 2019-12-24 17:23:38
问题 If I have io_service::run() running only in a single thread , are io_service::post() calls executed in the same order I request them to be executed, or they can be executed in arbitrary order and I still need to use strand for forcing serialized execution? 回答1: The question has been treated before, e.g. Does boost::asio::io_service preserve the order of handlers?? Documentation: Oreder Of Handler Invocations It clearly spells out if any of the following conditions are true: s.post(a) happens

Boost ASIO HTTP client POST

て烟熏妆下的殇ゞ 提交于 2019-12-24 16:25:19
问题 I am trying to get boost ASIO library to send a post but the variables never make it to the server. I know the server is working properly (tested with curl) This code does not work (the variable msg is not posted to the server) but it does work when I use curl tcp::resolver resolver(io_service); tcp::resolver::query query("localhost", "3000"); // "http"); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); tcp::resolver::iterator end; tcp::socket socket(io_service); boost:

Where can I download a ca.pem file for boost::asio::ssl?

╄→гoц情女王★ 提交于 2019-12-24 14:28:25
问题 In the example of doc/html/boost_asio/example/cpp03/ssl/client.cpp - 1.58.0, it loads a file named ca.pem , but where can I download it? I've tried to export one from Firefox, and also tried to use the one in my system such as /usr/share/ca-certificates/mozilla/GeoTrust_Global_CA.crt , but the example program only returns message Verifying /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA Handshake failed: certificate verify failed Any suggestion? Thanks a lot. 回答1: You can use Mozilla certificate

Handling boost asio timer cancelation

≯℡__Kan透↙ 提交于 2019-12-24 14:10:01
问题 Consider the following code that simulates a synchronous connect with timeout using async connect: { boost::asio::steady_timer timer{io_service, timeout}; timer.async_wait([&socket](boost::system::error_code const& code) { if (!code) socket.close(); }); auto future = boost::asio::async_connect(socket, endpoint, boost::asio::use_future); future.get(); } /* detect post-success cancelation? */ if (!socket.is_open()) { } If I understand asio documentation correctly, I cannot guarantee that the

Boost ASIO, async_read_some callback not called

我怕爱的太早我们不能终老 提交于 2019-12-24 13:52:41
问题 My code works for read_some , but not for async_read_some . The data I'm reading is 5 chars long, whereas MAX_RESPONSE_SIZE 256 . I call async_read_some once from my main after opening the port, but the callback is never called after I swipe my prox card a few times. I have tried adding io_service.run() after async_read_some but it did not help. Am I missing something? Thank you. header boost::system::error_code error; boost::asio::io_service io_service; typedef boost::shared_ptr<boost::asio:

Linking boost_1_55_0 asio

倖福魔咒の 提交于 2019-12-24 12:05:52
问题 I'm using this in my makefile to build my program: all: server.cpp g++ -o server server.cpp -I ~/boost/include -L~/boost/lib -Wl,-rpath,~/boost/lib -lboost_system -lboost_thread -DBOOST_ALL_NO_LIB=1 When I compile I get these warnings: /usr/bin/ld: warning: libboost_system.so.1.53.0, needed by /usr/local/lib/libboost_thread.so, may conflict with libboost_system.so.5 When I run my program I receive the warning : ./server: error while loading shared libraries: libboost_thread.so.1.53.0: cannot

How does beast async_read() work & is there an option for it?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 10:55:16
问题 I am not very familiar with the boost::asio fundamentals. I am working on a task where I have connected to a web server and reading the response. The response is thrown at a random period, i.e. as and when the response is generated. For this I am using the boost::beast library which is wrapped over the boost::asio fundamentals. I have found that the async_read() function is waiting until it is receiving a response. Now, the thing is : in documentations & example the asynchronous way of