boost-asio

boost::asio and socket ownership

半城伤御伤魂 提交于 2019-12-10 17:53:19
问题 I've two classes (Negotiator, Client), both has their own boost::asio::ip::tcp::socket. Is there a way to transfer socket object to Client after negotiation is finished. I'm looking forward to do something like that: boost::asio::ip::tcp::socket sock1(io); //... boost::asio::ip::tcp::socket sock2; sock2.assign(sock1); This operation must guarantee that the connection won't be closed when sock1 is destroyed. 回答1: I think that you could: obtain sock1's native handle with the native() member

boost::asio convert socket to secure

梦想与她 提交于 2019-12-10 17:47:55
问题 I'm writing a server for the game Minecraft in C++. The client sends an initial handshake packet to the server through a normal socket. The server then sends an RSA key back to the game and all socket communication from that point onwards becomes AES encrypted with the RSA key sent to the client. I had an idea that I could avoid implementing AES/RSA and linking to other libraries in my server by simply transforming my regular boost::asio socket into a boost::asio ssl socket directly after the

boost::asio::io_service crash in win_mutex lock

回眸只為那壹抹淺笑 提交于 2019-12-10 17:28:40
问题 I've been having a problem with boost::asio where timer and/or sockets created using a global io_service instance crash during construction. The system where the crash occurs is as follows: Windows 7 Visual Studio 2013 Express for Windows Desktop; v 12.0.31101.00 Update 4 Boost 1.57, dynamically linked, compiled with multithreading as, e.g. boost_thread-vc120-mt-gd-1_57.dll I've been able to replicate the issue in the following simplified code: // file global_io_service.h #ifndef INCLUDED

Limitations to using (Boost) Asio with Android NDK

佐手、 提交于 2019-12-10 17:10:02
问题 What are the current limitations for using Asio with NDK on Android platforms? Would there be any other choice that you would definitely choose over Asio? 回答1: As such no limitation. Only concern is lack of official support. You would have to build boost libraries refer my post https://stackoverflow.com/posts/comments/19511559 thanks 来源: https://stackoverflow.com/questions/14108859/limitations-to-using-boost-asio-with-android-ndk

Is there a boost::iostreams (bidirectional) Device for a blocking boost::asio TCP connection?

南楼画角 提交于 2019-12-10 16:38:56
问题 I'm surveying c++ libraries for portable, blocking I/O access to the filesystem and network. It looks like boost::filesystem , boost::iostreams and boost::asio will, between the three of them, do the job. To be clear, I'm not currently interested in the asynchronous aspects of boost::asio ; I just want a portable, blocking interface to the network. Digging in, I see boost::iostreams has a notion of Devices, each of which has an associated mode concept. The bidirectional mode specifically

ThreadPool using ASIO - Threads Exit, Task not performed

Deadly 提交于 2019-12-10 16:31:28
问题 I am writing a ThreadPool Class in C++ using Boost ASIO. The following is the code that I have written so far: The ThreadPool Class using namespace std; using namespace boost; class ThreadPoolClass { private: /* The limit to the maximum number of threads to be * instantiated within this pool */ int maxThreads; /* Group of threads in the Pool */ thread_group threadPool; asio::io_service asyncIOService; void _Init() { maxThreads = 0; } public: ThreadPoolClass(); ThreadPoolClass(int

undefined reference with boost when I try to compile

♀尐吖头ヾ 提交于 2019-12-10 15:26:41
问题 i have lot of errors when i try to compile my server with boost. Here, this is my makefile : NAME = serveur SRCS = Serveur/main.cpp \ Serveur/Client.cpp \ Serveur/Commande.cpp \ Serveur/My_exception.cpp \ Serveur/Network.cpp \ Serveur/Server.cpp ##################################################### OBJS = $(SRCS:.cpp=.o) CC = g++ RM = rm -f CFLAGS = -g -W -Wall -Werror INCL = ./Serveur/boost_1_47_0 LIB = ./Serveur/boost_1_47_0/stage/lib/ NLIB = -lboost_system -lboost_system-mt -lboost

Boost::asio::ssl OpenSSL not compiling

旧城冷巷雨未停 提交于 2019-12-10 14:55:34
问题 I'm using boost::asio::ssl. I have installed openssl via sudo apt-get install openssl. In my makefile I link openssl via -lssl. When compiling I am getting the error: fatal error: openssl/conf.h: No such file or directory Can anyone tell me what I'm missing or if I'm including the library incorrectly? 回答1: You may not have the necessary development files. Try installing the libssl-dev package with sudo apt-get install libssl-dev this may solve your problem 来源: https://stackoverflow.com

Why doesn't this Boost ASIO code work with this python client?

£可爱£侵袭症+ 提交于 2019-12-10 14:41:09
问题 This code is identical to the original udp async echo server, but with a different socket. The response is transmitted and showing in wireshark, but then an ICMP Port Unreachable error is sent back to the server. I'm trying to understand why because everything looks correct. You can copy this code directly into a source file e.g. server.cpp. and then compile with gcc server.cpp -lboost_system Run it with a command like: ./a.out 35200 #include <cstdlib> #include <iostream> #include <boost/bind

Boost Asio On Linux Not Using Epoll

好久不见. 提交于 2019-12-10 14:22:48
问题 I was under the impression that boost::asio would use an epoll setup by default instead of a select implementation, but after running some tests it looks like my setup is using select. OS: RHEL 4 Kernel:2.6 GCC:3.4.6 I wrote a little test program to verify which reactor header was being used, and it looks like its using the select reactor rather than the epoll reactor. #include <boost/asio.hpp> #include <string> #include <iostream> std::string output; #if defined(BOOST_ASIO_EPOLL_REACTOR_HPP)