boost-asio

Modifying the autolayout engine from a background thread error, from C++

瘦欲@ 提交于 2019-12-11 23:26:27
问题 I get the following error in Xcode 7.1 when making a UI call from C++, through a two-way djinni architecture: This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release. I am able to solve the problem in Objective-C with the solution given here: Getting a “This application is modifying the autolayout engine” error? dispatch_async(dispatch_get_main_queue(), ^{ // code here

boost asio async_read: the read message adds to itself

蓝咒 提交于 2019-12-11 22:22:02
问题 I use my PC as a server. The client sends messages like: "PART1:Part2", and the server performs the necessary actions. I use boost's asio for the server code. void start_read() { boost::asio::async_read(socket_, input_buffer_, boost::asio::transfer_at_least(1), boost::bind(&tcp_connection::handle_read, shared_from_this(), boost::asio::placeholders::error)); } // When stream is received handle the message from the client void handle_read(const boost::system::error_code& error) { if (!error) {

boost async_receive_from ip filter

a 夏天 提交于 2019-12-11 20:29:19
问题 I'm using boost::asio to capture packets on udp port. I'm just new to boost. How can I make async_receive_from copy data to buffer only packets with specified source ip? 回答1: Depending on what you mean by capture packets, some code like this would work. This is modified from Boost Asio Async UDP example. socket_ is connected to a local interface at a specified port if you set port to 0 I believe it listens on all the ports. Once you receive a packet using async_receive_from , it will also

Using Boost.asio in Visual C++ Forms project with dynamic link libraries and using #define BOOST_ALL_DYN_LINK still same errors

纵然是瞬间 提交于 2019-12-11 18:53:45
问题 I'm using visual studio 2010 I built boost using b2 toolset=msvc-10.0 --build-type=complete --libdir=C:\Boost\lib\i386 install And I'm trying to run a lan file sharing client console application that works perfectly from a c++ forms applications. So i added #include <boost/config/user.hpp> #define BOOST_ALL_DYN_LINK to stdafx.h arcording to this! but i get the same errors. 1>C:\Boost\include\boost-1_54\boost/system/error_code.hpp(213): warning C4272: 'boost::system::system_category' : is

TCP socket sending less number of bytes

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 18:45:12
问题 I am trying to send a large number of bytes using boost.asio library as following: void tcp_send(boost::asio::io_service &io, const char *dst_ip, uint16 dst_port) { uint8 *sbuff; size_t slen; ip::tcp::socket sock(io); sock.connect(ip::tcp::endpoint(ip::address::from_string(dst_ip), dst_port)); sbuff = new uint8[100412]; sbuff[0] = 67; sbuff[1] = 193; sbuff[2] = 136; sbuff[3] = 60; boost::asio::async_write(sock, boost::asio::buffer(sbuff, 100412), boost::bind((&send_handler), placeholders:

When use async_write_some and async_write

浪子不回头ぞ 提交于 2019-12-11 16:52:35
问题 I was reading the documentation of Boost Asio and it says that boost::asio::async_write_some may NOT transfer all of the data to the peer. Consider using the async_write function if you need to ensure that all data is written before the asynchronous operation completes. So here is my question, in which cases should we use them, isn`t VERY important to ensure that all the data is written?! when to use async_write_some just this function seems to me useless? 回答1: async_write is useful in

UDP Connect Always Succeeds

只愿长相守 提交于 2019-12-11 15:38:18
问题 I am using Boost ASIO to connect to an Arduino Nano with an Ethernet Shield over ethernet. This is the Arduino setup: #include <EtherCard.h> ether.staticSetup("10.0.0.4", "10.0.0.1"); ether.udpServerListenOnPort(&callback_function, 1337); This is my C++ code that connects to it: Header #include <boost/asio.hpp> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/bind.hpp> #include <boost/thread.hpp> #include <boost/system/error_code.hpp> #include <boost/system

Boost asio non-blocking IO without callbacks

蓝咒 提交于 2019-12-11 13:37:37
问题 Is it possible to use Boost's asio to do non-blocking IO without using async callbacks? I.e. equivalent to the O_NONBLOCK socket option. I basically want this function: template<typename SyncWriteStream, typename ConstBufferSequence> std::size_t write_nonblock( SyncWriteStream & s, const ConstBufferSequence & buffers); This function will write as many bytes as it can and return immediately. It may write 0 bytes. Is it possible? 回答1: Yes, using the non_blocking() method to put the socket into

How to get boost::asio::io_service current action number

杀马特。学长 韩版系。学妹 提交于 2019-12-11 13:31:13
问题 Boost::asio::io_service provides "handler tracking" for debugging purposes, it is enabled by defining BOOST_ASIO_ENABLE_HANDLER_TRACKING but logs its data to stderr. I'd like to use this tracking information in my application. My question is what is the best way to get access to the <action> inside my application? For more context as to why I want to do this; I would like to attach the <action> as a parameter to other async operations so that I can track where the originating request came

Boost: Re-using/clearing text_iarchive for de-serializing data from Asio:receive()

别等时光非礼了梦想. 提交于 2019-12-11 13:14:55
问题 This is my current function that de-serializes data received via Boost:Asio UDP transmission. It works perfectly, however the performance is pretty bad. About 4000 or so calls per second will use ~16% of CPU, which is a full thread of an I7. Running a performance test on the code shows that this line uses >95% of the cpu time: text_iarchive LLArchive(LLStream); My question is simple: is there a way I can re-use a text_iarchive without having to create a new one each time the function is