boost-asio

How to use boost asio library with Cygwin 64 bit

天大地大妈咪最大 提交于 2019-12-12 08:58:26
问题 I am running Windows 10 64bit. Cygwin is 64 bit. I installed boost from cygwin package manager. I tried to compile test.cpp: #include <boost/asio.hpp> int main(int argc, char**argv) { return 0; } using command g++ -std=c++11 -Wall -g -D__USE_W32_SOCKETS D_WIN32_WINNT=_WIN32_WINNT_WIN7 test.cpp -o test.exe but compile fails. It looks like posix is being used . Any ideas why this fails? In file included from /usr/include/boost/asio/detail/fd_set_adapter.hpp:22:0, from /usr/include/boost/asio

Help streaming over http in C++

浪子不回头ぞ 提交于 2019-12-12 08:57:20
问题 I'm looking to use a web service that offers a streaming api. This api can typically be used by the java method java.net.URL.openStream(); Problem is I am trying to design my program in C++ and have no idea what libraries (I've heard the cUrl library is very good at this sort of thing) to use, or how to use them to do what I want. The idea is that after opening the file as a stream I can access continually updating data in realtime. Any help would be much appreciated. 回答1: Boost.Asio socket

boost asio and endian

两盒软妹~` 提交于 2019-12-12 08:36:46
问题 I cant tell, does boost asio handle endian? 回答1: Asio does convert things like port into network order. The conversion functions are not exposed as part of the official interface and are hidden in the detail namespace instead (e.g. boost::asio::detail::socket_ops::host_to_network_short ). 回答2: boost::asio::socket_'s do not perform any byte order conversion. 来源: https://stackoverflow.com/questions/524453/boost-asio-and-endian

Boost error codes human-readable description

巧了我就是萌 提交于 2019-12-12 08:19:36
问题 I'm catching errors in Boost Asio program like if (!error) { //do stuff } else { std::cout << "Error : " << error << std::endl; //handle error } But the error isn't human-readable (e.g. connecting to SSL server without certificate gives error asio.ssl:335544539). Is there any better way how to display error ? 回答1: If you are likely using boost::system::error_code you can call: error.message() to get a more human-friendly message. Using operator<< translates into: os << ec.category().name() <<

Using boost.asio in cMake

偶尔善良 提交于 2019-12-12 08:04:31
问题 I am relatively new to cMake, and I'm trying use the boost asio library in my project. I was able to get cMake to find other boost libraries such as smart_ptr and lexical_cast, but I get a linker error when I try to include boost/asio.hpp : LINK : fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-1_40.lib'. I then tried to change my CMakeLists.txt from find_package(Boost 1.40.0 REQUIRED) to find_package(Boost 1.40.0 REQUIRED COMPONENTS asio) cMake then asks for Boost_ASIO_LIBRARY

Destroying server instance : ASIO C++

狂风中的少年 提交于 2019-12-12 06:07:44
问题 Referring to HTTP Server- Single threaded Implementation I am trying to Explicitly control Lifetime of server instance My Requirements are: 1) I should be able to explicitly destroy the server 2) I need to keep multiple Server Instances alive which should listen to different ports 3) Manager Class maintains list of all active server instances; should be able to create and destroy the server instances by create and drop methods I am trying to implement Requirement 1 and I have come up with

How can I setup a deadline_timer in this environment?

不羁的心 提交于 2019-12-12 05:27:32
问题 I am a bit lost in a construct of libraries, which I have to tangle together. I need help to indtroduce some timers into this construct. I have the following: com.cpp which has main and includes com.hpp com.hpp which includes a host.h and needed boost includes and defines a class comClient host.c with included host.h wrapper.cpp with included com.hpp and some needed boost includes Now, my com.cpp is creating a comClient and uses it for asynch communication on the com-port. Using boost::asio:

Boost C++ UDP example can not transmit over internet

筅森魡賤 提交于 2019-12-12 05:00:02
问题 Hello i am experimenting with Boost C++ UDP client-server. I took the one of the examples that comes with ASIO and modified it a bit. It works very well on local network but when i host the server to one of our servers with ports correctly forwarded, it doesn't work. I run the UDP server and try to transmit with the client from home over the internet but none of the packets arrive to the server. I am sure that the ports are forwarded correctly and that the firewall is not getting in the way.

How to send an std::vector<unsigned char> using asio::UDP socket.send_to

断了今生、忘了曾经 提交于 2019-12-12 04:58:33
问题 I am trying to synchronously send an std::vector<unsigned char> through boost::asio::ip::udp from my server app to client app with following code like this: boost::system::error_code ignored_error; std::vector<unsigned char> buf_data; std::size_t len = socket.send_to(boost::asio::buffer(buf_data), remote_endpoint, 0, ignored_error); This causes a hang & socket.send_to never returns. However, If I try to send a struct like below, it works nicely struct MyStruct { char name[1024]; int age; };

Check if boost::asio buffer data is present before read()

↘锁芯ラ 提交于 2019-12-12 04:40:03
问题 I'm trying to port a piece of software I wrote with Unix sockets to a version with TCP sockets, using boost::asio. The program is intended to run on a Linux machine. In the earlier version of the code (using Unix sockets) I used a simple check to see if there was new data on the socket buffer, and then proceeding with reading predictably structured data: ioctl(s_c, FIONREAD, &socketstatus); while (socketstatus > 0) {// do receive stuff ioctl(s_c, FIONREAD, &socketstatus);} Is there any way to