boost-asio

HOW-TO: Client connection manager for Boost::asio?

Hi, I created a server using boost:asio. When a client connects it sends a file_size, file_name and the file_data. The server stores this in a file on disk. This works perfectly! Though now I'm running both client application and server application in the main thread of their application (so I've got a server and client app) which block...

c++ boost asio timeout for blocking connect

I have a C++ boost client that does a blocking connect and processes the message once it receives a response. I am facing a strange issue. tcp::resolver::query query(tcp::v6(), this->host, port,tcp::resolver::query::v4_mapped); iterator = resolver.resolve(query); socket = new tcp::socket(io_service); socket->connect(*iterator); I tri...

boost::asio async_accept Refuse a connection

Hello, My application have an asio server socket that must accept connections from a defined List of IPs. This filter must be done by the application, (not by the system), because it can change at any time (i must be able to update this list at any time) The client must receive an acces_denied error. I suppose when the handle_accept ...

boost deadline_timer question

I expected the code below to print Hello, world! every 5 seconds, but what happens is that the program pauses for 5 seconds and then prints the message over and over with no subsequent pauses. What am I missing? #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> using namespace boost::as...

interaction problem with boost.signals2 ?

Hello. I'm trying to call a signal after an booost::asio::async_read from inside a function called by boost::asio::io_service. The run function runs in a thread, and the observers are connected in a different thread. This is causing errors. It's my program or it's not possible to invoke a handler that is running in another thread from i...

TFTP source code examples

Could someone point me to the source code for an ideally multi-threaded C++ TFTP application. Even better if it's written using boost asio. Just wanting to get an idea of how to structure a multi-threaded c++ network app with UDP rather than TCP. I'll choose the answer based on how readable the code is and being in C++. ...

boost::asio - Clarification on binding to a specific network interface

Hi All, I've been searching the net for answers but I can't seem to find a complete answer. Scenario: I have a client API and a server. An application uses the client API to talk to the server. Both TCP and UDP are used to communicate between the client API and the server. All of this has been written using ASIO. The client API conn...

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

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. serv...

How can I wrap std::wstring in boost::asio::buffer ?

I am writing a client server application using boost::asio. I want to transfer a structure from a client to the server. The struct has a few std::wstrings in it. How do I encode the structure in boost::asio::buffer? ...

How to put Apache Thrift behind Boost Asio?

As far as I see Thrift documentation/examples/tutorials is very limited. A single example on C++ shows how to attach Thrift handler to a socket. I would like to wrap it into Boost::Asio-based http server. Please, if somebody have links to some already published experience on this matter, please tell me, I found nothing. Or, at least, g...

UDP socket network disconnect behavior on Windows-Linux-Mac

Hi folks, I made an application using boost.Asio using UDP multicast. I don't think the question is really specific to boost.Asio but to sockets programming in general, since boost.Asio's network facilities are mostly wrappers to socket functions. I constructed the application based on the multicast examples ( http://www.boost.org/doc/...

Is it safe to manipulated streambuf after doing boost::asio::async_read?

I know it's not safe to manipulated streambuf while async_write working as stated by asio author on boost mailing list. What I want to know is, is it safe to manipulated streambuf after async_read? Example: async_read(socket_, recv_streambuf_, ...); // manipulated while async_read is working // for example, after I call async_read, rec...

boost shared_from_this<>()

Hello all, could someone summarize in a few succinct words how the boost shared_from_this<>() smart pointer should be used, particularly from the perspective of registering handlers in the io_service using the bind function. EDIT: Some of the responses have asked for more context. Basically, I'm looking for "gotchas", counter-intuitive ...

question about boost asio

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 ...

Boost Asio problems, Server-Client, Slow on a real network?

I have created a client-server architecture using Boost Asio. The entire thing works, I can send and receive messages, etc, so there is no question about the correctness. However, when I implement it in a real network, all of a sudden it becomes VERY slow. When I run the server and client on the same computer itgoes blazingly fast, but ...

How to create a boost ssl iostream?

I'm adding HTTPS support to code that does input and output using boost tcp::iostream (acting as an HTTP server). I've found examples (and have a working toy HTTPS server) that do SSL input/output using boost::asio::read/boost::asio::write, but none that use iostreams and the << >> operators. How do I turn an ssl::stream into an iostre...

Why doesn't this boost asio code work correctly?

This boost udp server doesn't function as expected. It is identical to the blocking UDP echo server EXCEPT for a minor change. I'm using a different socket to return the response, i.e. sock2. Now this code works perfectly if the client is on the same machine as the server. But the moment I run this on a different machine, the response i...

boost::asio::async_read and boost::asio::streambuf

I am using async_read with streambuf. However, I would like to limit the amount of data read to 4, so I can properly handle header before going to body. How can I do that using async_read? ...

List active handlers in boost io_service

Whilst building unit tests for a client/server system at work, I ran into a problem where my io_service was not releasing after I had shutdown all the active handlers (that I was aware of). After a day of trawling through code, I came across the errant handler which had not been integrated into my client shutdown procedures. My questio...

boost.asio. The possibility to expect the completion of any object in queue is necessary.

In asio:: io_service I insert objects. asio:: io_service::run() runs in several threads. The possibility to expect the completion of any object in queue is necessary. For example: template <typename T> struct handler { void operator()() { .... } T get() const {...} }; asio::io_service ios; ios.post(handler()); How I c...