boost-asio

C++ boost::bind with std::shared_ptr trowing operation canceled on timeout handler

你说的曾经没有我的故事 提交于 2019-12-12 04:19:21
问题 I´m trying to build an asynchronous server using boost::asio . The server is read only and needs to have a session timeout: If a session passes more than N seconds without receiving data, the session is disconnected and the client needs to start the connection again. SocketServer.hpp class SocketServer { public: SocketServer(boost::asio::io_service& service); virtual ~SocketServer(); void StartAsync(int port); void StopAsync(); private: void StartAccept(); void HandleAccept(std::shared_ptr

boost::asio handshake through http proxy?

ε祈祈猫儿з 提交于 2019-12-12 04:03:09
问题 Quite new to boost and asio, need help: connect to proxy asio::ip::tcp::socket socket_; send CONNECT host: ssl server to the proxy receive response 200 asio::ssl::context ctx(io_service, asio::ssl::context::sslv23); sslsocket_(socket_,context) try handshake sslsocket_.async_handshake(asio::ssl::stream_base::client, boost::bind(&client::handle_handshake, this, asio::placeholders::error)); and get asio.ssl error Wireshark: host sends FIN after 1st message of handshake Direct async connection to

Is there a framework/app for testing distributed systems or just network apps?

陌路散爱 提交于 2019-12-12 03:24:52
问题 I want to simulate at least 9 clients to test my p2p engine. And i want to make some of them to be behind NAT and some of them to have all ports unlocked. Also, i would like to see log which creates each of them. I am not capable of running 9VM simultaneously, so I'm here to ask experts: is there something i can use for testing it? I am using Boost library in my app. 回答1: I think that's the perfect solution for linux users: http://www.nrl.navy.mil/itd/ncs/products/core I will keep this answer

sending doubles via TCP between Boost ASIO server and Java client

对着背影说爱祢 提交于 2019-12-12 02:53:30
问题 I am trying to set up a simple Boost ASIO server with a single Java client. I am able to send and successfully receive strings between the two. However, when I try to send double values, only garbage comes out on the other end. Below is stand alone code that shows my basic setup (with a C++ Boost ASIO server and a Java client). When they are run, they do the following four sequential tasks: The client sends a string to the server, which is successfully received and printed out. The server

Boost::Asio synchronous client with timeout

偶尔善良 提交于 2019-12-12 01:48:44
问题 I´m trying to build a synchronous FTP client code with timeout using a thread as the timeout control. The thread will be started on every transaction and will close the socket in case of timeout - that will force the syncronous call to return with error. So here is my code: #include <cstdlib> #include <cstring> #include <iostream> #include <thread> #include <chrono> #include <boost/asio.hpp> #define TIMEOUT_SECONDS 5 #define MAX_MESSAGE_SIZE 4096 using boost::asio::ip::tcp; enum { max_length

Boost Asio Peek and Completion Condition

笑着哭i 提交于 2019-12-12 01:48:06
问题 I am using Boost Asio to set up a socket connection. I would like to peek at the data in the buffer without consuming it, and I would like to use a completion condition to ensure that I could stop the blocking call if necessary. I can get the peek functionality from basic_stream_socket::receive: template< typename MutableBufferSequence> std::size_t receive( const MutableBufferSequence & buffers, socket_base::message_flags flags, boost::system::error_code & ec); One of the possible message

Boost-ASIO simple echo client-server cannot establish connection?

吃可爱长大的小学妹 提交于 2019-12-12 01:29:48
问题 I'm using BOOST-ASIO for a simple echo client-server (there is a separate link for the client and server). When I try to run the server I use this async_tcp_echo_server 4000 . For the client I use blocking_tcp_echo_client #.#.#.# 4000 (with #.#.#.# as the ip address). I'm on XP-SP3 with my computer connected to my wireless dsl modem using a usb card. After a few seconds on the client side I get this error: Exception: connect: A connection attempt failed because the connected party did not

boost asio ssl async_write send me mostly gibberish

僤鯓⒐⒋嵵緔 提交于 2019-12-12 01:22:16
问题 I'm in the process of converting my non secure socket to ssl, using boost::asio::ssl While everything was working fine with non-ssl, async_write send me mostly gibberish. The funny thing is when I put a sleep(1) between every async_write, I get mostly good data, with a little gibberish (something like that "?????@??" ) The faster I send data the most gibberish it gets... I'm completely lost on this problem ! initSSLConnection : boost::asio::ssl::context *m_context = new boost::asio::ssl:

question about boost asio

馋奶兔 提交于 2019-12-12 00:38:44
问题 i have following code #include <boost/date_time/posix_time/posix_time.hpp> #include <iostream> #include <boost/asio.hpp> using namespace std; int main(int argc,char *argv[]) { boost::asio::io_service io; boost::asio::deadline_timer t(io,boost::posix_time::seconds(5)); t.wait(); std::cout<<" hello world\n"; return 0; } but i have following error list /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf make[1]: Entering directory `/home/david/NetBeansProjects/Boost' /usr/bin

Declaring a boost asio socket, acceptor and endpoint in a class headerfile

 ̄綄美尐妖づ 提交于 2019-12-12 00:28:32
问题 I have a TCP/IP server made with boost asio that is wrapped in a class. Now i want declare the socket, eindpoint and acceptor in the class headerfile so that i can make memberfunctions that use the socket. The server runs now in the class constructor. I tried to use a initialiser list like below: CommunicationModuleTCPIP::CommunicationModuleTCPIP(bool Server, string IPAdress, int PortNumber) : Sock(new boost::asio::ip::tcp::socket(IOService)); { // Constructor code But this gives compiler