boost-asio

Errors using same port on different machines

限于喜欢 提交于 2019-12-14 03:32:26
问题 I have written an application ( called M2 ) which reads data arriving on one port, processes it, then sends the results out to another port. If I choose to send data to 193.168.1.101:5001 everything works. If I send to 192.168.1.101:5001 it does not. Why should changing the first byte of the IP address make any difference? The reason for the change is that when I trasmit a packet to 193.168.1.101:5001 then it takes about a millisecond, but when I transmit to 192.168.1.101:5001 it takes over a

undefined reference to `std::errc::operation_canceled` when compiling websocketpp example code with mingw

不打扰是莪最后的温柔 提交于 2019-12-14 02:48:38
问题 I'm trying to use websocketpp to write a cross-platform program that communicates using websockets. I would like to use the asio -based transport layer. My understanding was that if I am using C++11, I can configure asio to stand-alone from boost and use std::thread , and that websocketpp is similarly header-only under such circumstances. However, when I actually try to compile any of the websocketpp tutorials this way, such as the tutorials/utility_client , it works fine on g++ and clang,

boost asio need to post n jobs only after m jobs have finished

梦想的初衷 提交于 2019-12-14 02:43:22
问题 I'm looking for a way to wait for a number of jobs to finish, and then execute another completely different number of jobs. With threads, of course. A brief explanation: I created two worker threads, both executing run on io_service. The code below is taken from here. For the sake of simplicity, i had created two types of jobs, CalculateFib i CalculateFib2 . I want the CalculateFib2 jobs to start after and only after the CalculateFib jobs finish. I tried to use condition variable as explained

Can ASIO timer `cancel()` call a spurious “success”?

偶尔善良 提交于 2019-12-14 02:29:31
问题 The ASIO documentation for basic_deadline_timer::cancel() has the following remarks section: If the timer has already expired when cancel() is called, then the handlers for asynchronous wait operations will: have already been invoked; or have been queued for invocation in the near future. These handlers can no longer be cancelled, and therefore are passed an error code that indicates the successful completion of the wait operation . The emphasis has been added by me. Normally when you call

Weird output for a tutorial in boost asio doc

有些话、适合烂在心里 提交于 2019-12-13 21:04:38
问题 In the 5th tutorial, of which the code I have given at bottom of the question, asio documentation introduced the output comes as follows : Timer 2: 0 Timer 1: 1 Timer 2: 2 Timer 1: 3 Timer 2: 4 . . . After the first one it is as expectable, with the sequence. But even though Timer1 is wrapped in the strand first, why does Timer 2 starts running first ? #include <iostream> #include <asio.hpp> #include <boost/bind.hpp> #include <boost/date_time/posix_time/posix_time.hpp> class printer { public:

how to clean boost::asio::ssl::stream after closed by server

╄→尐↘猪︶ㄣ 提交于 2019-12-13 17:56:26
问题 Currently I am developing a gateway to connect apns to push notification. Apns will close the ssl socket when the connection is idle for about one hour. Sometimes when I reconnect, boost.asio keep telling me that handshake fail with error code 335544539. When apns close the connection, I will call socket.close(), but I didn't shutdown ssl stream. How could I clean ssl stream so that I could reconnect by using the old ssl stream? 来源: https://stackoverflow.com/questions/25263381/how-to-clean

Low bandwidth performance using boost::asio::ip::tcp::iostream

三世轮回 提交于 2019-12-13 17:34:40
问题 I have written a small test program that uses boost::asio::ip::tcp::iostream to transmit about 38 MiB of data: #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/asio.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/vector.hpp> #include <chrono> #include <iostream> #include <sstream> #include <string> #include <thread> using namespace std; class Message { public:

C++:BOOST-bind error: no matching function for call to 'bind(<unresolved overloaded function type>, …?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 15:37:43
问题 I tried to turn this boost-asio server into a class and I got this one error trying to compile it, C:\Documents and Settings\tcpip_server\TCPIP_server.h||In member function 'void TCPIP_server::server(boost::asio::io_service&, short int)':| C:\Documents and Settings\tcpip_server\TCPIP_server.h|56|error: no matching function for call to 'bind(<unresolved overloaded function type>, boost::shared_ptr<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost:

Boost Asio SSL Certification on iOS

孤街醉人 提交于 2019-12-13 15:01:47
问题 I am trying to use Boost Asio on iOS, and have figured out everything, but how to check the certificate of the server I am connecting to. How do you check the connecting server's certificate in iOS with Boost Asio? 回答1: In another answer of mine you can see a simple SSL client. In this code you'll quickly note verify_certificate which you can use to (additionally) verify the server certificate. Sidenote Note that I don't know which libraries are underlying the Asio SSL implementation iOS, but

boost deadline_timer issue

你离开我真会死。 提交于 2019-12-13 13:41:48
问题 Here follows the implementation of a test class wrapping a thread with a timer. The strange thing is that if the deadline is set to 500 milliseconds it works but if I set it to 1000 milliseconds it does not. What am I doing wrong? #include "TestTimer.hpp" #include "../SysMLmodel/Package1/Package1.hpp" TestTimer::TestTimer(){ thread = boost::thread(boost::bind(&TestTimer::classifierBehavior,this)); timer = new boost::asio::deadline_timer(service,boost::posix_time::milliseconds(1000)); timer-