boost-asio

What causes a random crash in boost::coroutine?

烂漫一生 提交于 2019-12-20 05:44:27
问题 I have a multithread application which uses boost::asio and boost::coroutine via its integration in boost::asio . Every thread has its own io_service object. The only shared state between threads are connection pools which are locked with mutex when connection is get or returned from/to the connection pool. When there is not enough connections in the pool I push infinite asio::steady_tiemer in internal structure of the pool and asynchronously waiting on it and I yielding from the couroutine

How to link ws2_32 in Clion

▼魔方 西西 提交于 2019-12-20 05:01:17
问题 I am using Clion, which uses MinGW and Cmake. When I try to use the standalone asio library I am getting undefined reference to `WSAStartup@8' undefined reference to `WSASetLastError@4' undefined reference to `closesocket@4' ... I believe I have to link the C:/Windows/System32/ws2_32.dll library. I tried adding something like -L C:/Windows/System32 -lws2_32 : set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS} -static -lws2_32") But that didn't help. How can I fix

How to link ws2_32 in Clion

让人想犯罪 __ 提交于 2019-12-20 05:01:13
问题 I am using Clion, which uses MinGW and Cmake. When I try to use the standalone asio library I am getting undefined reference to `WSAStartup@8' undefined reference to `WSASetLastError@4' undefined reference to `closesocket@4' ... I believe I have to link the C:/Windows/System32/ws2_32.dll library. I tried adding something like -L C:/Windows/System32 -lws2_32 : set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS} -static -lws2_32") But that didn't help. How can I fix

Which io_context does std::boost::asio::post / dispatch use?

℡╲_俬逩灬. 提交于 2019-12-20 04:47:02
问题 While using boost::asio 1.66 I read in the documentation that boost::asio::io_context::post is deprecated for boost::asio::post , same for boost::asio::io_context::dispatch . Because before they where member functions of the io_context before, and of course the handler needs to be executed in the context of some io_context i.e. executor my question is: How does boost::asio::io_context::post simplest overload know which io_context i.e. executor to use? The documentation of template< typename

boost::asio with no_delay not possible?

旧巷老猫 提交于 2019-12-20 03:43:20
问题 What I know... I need to call set_option(tcp::no_delay(true)) before connect() according to https://stackoverflow.com/a/25871250 or it will have no effect. Furthermore, set_option() works only if the socket was opened beforehand according to https://stackoverflow.com/a/12845502. However, the documentation for async_connect() states that the passed socket will be closed if it is open before handling the connection setup (see async_connect()). Which means that the approach I chose does not set

ASIO example code closing socket before it should

瘦欲@ 提交于 2019-12-20 03:19:27
问题 I need a parallel synchronous TCP solution using ASIO. I'm trying to get the example code from these examples working: https://github.com/jvillasante/asio-network-programming-cookbook/tree/master/src (using the server in ch04: 02_Sync_parallel_tcp_server.cpp and the client in ch03: 01_Sync_tcp_client.cpp). The only thing I changed is the logging to append to text files. The problem is that while the server runs fine, the client dies after returning a single response from the server: libc++abi

Boost::Asio Async write failed

馋奶兔 提交于 2019-12-20 02:54:22
问题 I am porting an application which uses Boost::Asio to an embedded system. I have already cross-compiled boost 1.57.0 binaries for the board using its BSP. To test the libraries working, I ran two http server examples that use synchronized and asynchronized writing respectively. The Sync version runs fine; while the Async one failed at writing. It returned error "Operation canceled". Can anyone point out where I should look for? Thanks. /* * Boost::Asio async example */ #include <iostream>

boost asio iostream - how to get local IP address

狂风中的少年 提交于 2019-12-19 18:34:40
问题 Here is my problem: I'm using boost::asio::ip::tcp::iostream to connect to server: boost::asio::ip::tcp::iostream s(IP, "1237"); And now I want to retrieve my own, local IP address. I have found somewhere in the depths of google how to do it with a socket, but what about a stream? I expect that since tcp::iostream is built on the top of a socket it should be something like: s.local_endpoint().address() but after a long search with google and duckduckgo I have found no clue how to do it. I

boost asio iostream - how to get local IP address

心不动则不痛 提交于 2019-12-19 18:33:08
问题 Here is my problem: I'm using boost::asio::ip::tcp::iostream to connect to server: boost::asio::ip::tcp::iostream s(IP, "1237"); And now I want to retrieve my own, local IP address. I have found somewhere in the depths of google how to do it with a socket, but what about a stream? I expect that since tcp::iostream is built on the top of a socket it should be something like: s.local_endpoint().address() but after a long search with google and duckduckgo I have found no clue how to do it. I

boost asio iostream - how to get local IP address

◇◆丶佛笑我妖孽 提交于 2019-12-19 18:33:04
问题 Here is my problem: I'm using boost::asio::ip::tcp::iostream to connect to server: boost::asio::ip::tcp::iostream s(IP, "1237"); And now I want to retrieve my own, local IP address. I have found somewhere in the depths of google how to do it with a socket, but what about a stream? I expect that since tcp::iostream is built on the top of a socket it should be something like: s.local_endpoint().address() but after a long search with google and duckduckgo I have found no clue how to do it. I