boost-asio

C++ Boost.ASIO: passing accepted TCP connection from one opened socket to another using Windows APIs ( while works with Linux APIs)?

青春壹個敷衍的年華 提交于 2019-12-09 01:21:30
问题 I was trying to learn how to re assign accepted connection using Boost.ASIO and Windows API's. found this code sample added to it includes and use of namespaces so now it is compilable - just copy and paste and here you go... "The parameter is incorrect" exception at the same place code poster had it=( So here is code: #include <iostream> #include <boost/asio.hpp> #ifdef _WIN32 #include "Windows.h" #endif using namespace boost::asio::ip; using namespace std; int main(){ int m_nPort = 12345;

Boost::asio async_wait handler signature

与世无争的帅哥 提交于 2019-12-08 21:59:39
问题 I am going through the boost::asio examples. I am looking at Example 4 What is confusing is that, the WaitHandler in this example has the signature void print (this) But the async_wait call expects a handler whose function signature of the handler must be: void handler( const boost::system::error_code& error // Result of operation. ); Source: Boost documentation Since the parameter type is part of a function's signature, why in the example above, async_wait accepts a handler whose parameter

How to get *my* ip from udp endpoint

蹲街弑〆低调 提交于 2019-12-08 19:14:20
问题 Boost.Asio's udp::endpoint has a member that is remote address. Because I'm listening on multiple interfaces (like this): udp_socket(io_service, udp::endpoint(udp::v4(), port)) In my handler, I do not know which network interface received the packet. Without iterating over network interfaces and looking for a similarity between the endpoint address and my IP on each interface, can I get my IP for the interface that I got message from? 回答1: No. Boost.Asio does not expose the ability to

boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >

家住魔仙堡 提交于 2019-12-08 19:13:34
问题 I need some help with this exception, I am implementing a NPAPI plugin to be able to use local sockets from browser extensions, to do that I am using Firebreath framework. For socket and connectivity I am using Boost asio with async calls and a thread pool of 5 worker threads. Also I have a deadline per thread to implement a transmission timeout. My extension workflow with the plugin is as this: Open socket 1(this starts a async_receive and the deadline async_wait) Write in the socket 1 Get

Why does this program not receive the expected UDP packets?

我与影子孤独终老i 提交于 2019-12-08 16:15:58
问题 I am trying to receive a UDP packet using Boost asio. My code is based off of this blocking UDP client example from the asio documentation. I am trying to receive a BOOTP-like UDP packet from a C6655 TI DSP, which are being transmitted in 3 second intervals. I have Wireshark watching the same interface my program is listening on, and it can see the packets arriving (see below for the exact packet data, exported from Wireshark). The packets aren't really coming from the DSP, I captured one

ASIO UDP: class std::allocator<void> has no member named ‘construct’

亡梦爱人 提交于 2019-12-08 15:16:30
I have followed this example to set up an asynchronous UDP receive. But it fails on compilation: g++ -Wall -Wconversion -Wfatal-errors -Wextra -std=c++11 test1.cpp Error message: In file included from /usr/include/c++/5/ext/alloc_traits.h:36:0, from /usr/include/c++/5/bits/basic_string.h:40, from /usr/include/c++/5/string:52, from /usr/include/c++/5/stdexcept:39, from /usr/include/c++/5/array:38, from /usr/include/c++/5/tuple:39, from /usr/include/c++/5/functional:55, from /usr/include/c++/5/thread:39, from test1.cpp:1: /usr/include/c++/5/bits/alloc_traits.h: In instantiation of ‘static void

boost socket example stuck in while loop

大兔子大兔子 提交于 2019-12-08 14:19:41
问题 I am trying to learn boost asio socket. there is one interesting example in boost web page which set a deadline time to monitor the timeout and change async io to sync io fashion. but when I remove the deadline timer the program stuck in while loop in write_line, I don't understand why the connection can be setup but the socket write is stuck. it seems that the writing never finished ,the handler never called so the "ec" never changed. Thank you in advance!! #include <boost/asio/connect.hpp>

Reading messages from a serial port with Boost Asio

感情迁移 提交于 2019-12-08 12:46:07
问题 I would like to use Boost Asio to read variable length messages from the serial port. I would like to read and wait long enough to be sure that the line is idle, but I do not want to block completely. The following code is what I have so far, and I am in the process of testing it: long readData(void *_pData, unsigned long _uSize, size_t millis) { size_t n = 0; // n will return the message size. if (millis > 0) // millis is the acceptable idle time, 0 is invalid in my case. { size_t

How to use the same thread pool batch by batch

可紊 提交于 2019-12-08 07:54:45
问题 I found a good implementation of boost based thread pool which is an improvement over this and this . it is very easy to understand and test. It looks like this: #include <boost/thread/thread.hpp> #include <boost/asio.hpp> // the actual thread pool struct ThreadPool { ThreadPool(std::size_t); template<class F> void enqueue(F f); ~ThreadPool(); // the io_service we are wrapping boost::asio::io_service io_service; // dont let io_service stop boost::shared_ptr<boost::asio::io_service::work> work

iPhone unexpected duplication of TCP packets on different ports

让人想犯罪 __ 提交于 2019-12-08 07:53:04
问题 I'm running this simple asio-based program: Address address = Address::from_string(host); Tcp::endpoint ep(address, port); Tcp::resolver::iterator endpoint_iterator = resolver.resolve(ep); Tcp::socket socket(io_service); asio::connect(socket, endpoint_iterator); Everything works fine on my host machine, but when this program run under iOS (both iphone and iphonesimulator) my sniffer detect some unexpected packets: # client: 192.168.1.10, server: 192.168.1.100 # everything fine... 5.359761000