boost-asio

Compiling issues with boost

前提是你 提交于 2019-12-06 05:55:40
I'm having problems with compiling a program which includes "boost/asio.hpp". Compiling this program(taken from boost site): example.cpp: #include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> int main() { using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " ); } with c++ -I path/to/boost_1_55_0 example.cpp -o example works fine. But when the program includes: boost/asio.hpp And I'm trying to compile it with: g++ -I /usr/local/boost_1_55_0 example.cpp -o example -lboost

Boost asio: Send OpenCV IplImage from Ubuntu-Server to Win7-Client

浪尽此生 提交于 2019-12-06 05:54:27
I try to transmit an OpenCV IplImage from a Server (Ubuntu x64) to a Client (Win7 x64) using the boost asio library. The following code works fine if both (Client and Server) are on the same operating system. But when the server is on Ubuntu and the client on Win7 it doesn't work. The image header is correct, but something with the image data is wrong. I think this is because of the different bit-order between the two OS. Is it? How can I resolve this problem? And second: The transmission with this code is very slow. How can I improve the speed? Client: #define _WIN32_WINNT 0x0601 #include

map of pointers to functions of different return types and signatures

允我心安 提交于 2019-12-06 05:52:42
问题 I am looking for a way to call different functions by a string input. I have a map that ties each unique string to a function pointer and a lookup function to search the map and return a pointer if found. Now the trick is, I need a way to store and return pointers to functions with at least different return types, if possible, also with different signatures. The usage would be: Get a string input from a network socket -> find and execute the found function -> shove the result straight back

boost::asio: thread local asynchronous events

情到浓时终转凉″ 提交于 2019-12-06 05:51:41
问题 I will be creating x amount of threads in my server-app. x will be the amount of cores on the machine, and these threads will be (non-hyperthread) core-bound. Naturally with this scheme I would like to distribute incoming connections across the threads with the aim of ensuring that once a connection is assigned to a thread, it will only be served out of that particular thread. How is this achieved in boost::asio ? I am thinking: a single socket bound to an address shared by multiple io

Is it thread safe to call async_send and async_receive at the same time?

▼魔方 西西 提交于 2019-12-06 05:39:28
I understood that calling boost::asio::ip::tcp::socket::async_receive (or boost::asio::ip::tcp::socket::async_send ) two times may result in a bad behavior.. Is it OK if i call boost::asio::ip::tcp::socket::async_recive and boost::asio::ip::tcp::socket::async_send at the same time? I am going to have 2 or more threads running the boost::asio::run so you need to take that into account.. Thanks This has to be OK. How else would you perform full duplex async communications on a single service? You need a receive outstanding at all times for incoming data. The Boost docs indicate only that each of

What is the difference of boost asio serial_port_service and serial_port

不问归期 提交于 2019-12-06 05:27:40
问题 I am to implement a (hopefully) robust asynchronious serial rs232 data transmission (via USB) - for both windows and linux, including esp. that nice embedded system called beagle bone black. In the end I just want to be able to (compatibly) talk rs232 with robust deadline-timeouts, cancel() reset() etc. to not crash/hang when e.g. the tx or rx line disconnects accidently. So sure, I could simply copy/paste/adopt existing examples. But I also would like to become more enlightened ;-) I decided

Set timeout for boost socket.connect

爷,独闯天下 提交于 2019-12-06 05:21:24
I am using boost::asio::connect on a tcp::socket . When all goes fine, the connect returns immediately but on a poor network, the connect times out after a log wait of 15 seconds. I cannot afford to wait that long and so want to reduce the timeout. Unfortunately I have not come across any solution so far. I see solutions where async_wait is been used together with deadline_timer but all those examples are for receive / send operations and not for connect. Can anyone help me with a sample code for boost::asio::connect(socket, endpoints); . Requirement is that it should timeout in 5 seconds

How can I get a future from boost::asio::post?

房东的猫 提交于 2019-12-06 05:18:33
问题 I am using Boost 1.66.0, in which asio has built-in support for interoperating with futures (and for some time now). The examples I've seen online indicate how to achieve this cleanly when using networking functions such as async_read , async_read_some , etc. That is done by providing boost::asio::use_future in place of the completion handler, which causes the initiating function to return a future as expected. What kind of object do I need to provide or wrap my function in to get the same

Boost ASIO UDP client async_receive_from calls handler even when there are no incoming messages

佐手、 提交于 2019-12-06 05:15:05
I've modified the UDP client code from Boost daytime client tutorial into the following: class UDPClient { public: udp::socket* socket; udp::endpoint* receiver_endpoint; boost::array<char, 1024> recv_buffer; UDPClient(); void do_receive(); void handle_receive(const boost::system::error_code& error, size_t); }; UDPClient::UDPClient() { boost::asio::io_service io_service; udp::resolver resolver(io_service); udp::resolver::query query(udp::v4(), "127.0.0.1", "8888"); receiver_endpoint = new udp::endpoint(*resolver.resolve(query)); socket = new udp::socket(io_service); socket->open(udp::v4()); do

Boost asio priority and strand

让人想犯罪 __ 提交于 2019-12-06 05:07:00
I want to use boost asio for a message queue. I want to do different operations on different objects. The operations have a priority. So if there is a operation oft type A none of type B should be executed. To my understanding this is what the priority example in the boost dokumentation does. But what I as well need is, if there is one operation running in one object, i do not want to execute another operation in the same object. Is this something that can be done with boost asio? sehe The latter has nothing to do with priority queuing and everything with operation serialization. You can