boost-asio

Boost: how do we specify "any port" for a TCP server?

How can I specify "pick any available port" for a TCP based server in Boost? And how do I retrieve the port once a connection is accepted? UPDATED: By "available port" I mean: the OS can pick any available port i.e. I do not want to specify a port. ...

Simple interface for getting HTML content in Boost.Asio

There are a lot of examples how to make HTTP request to a server and get reply via boost.asio library. However, I couldn't find a good example of simple interface and wondering, if I need to implement it myself. For instance, if I need to get content of http://www.foo.bar/path/to/default.html, is there any way to get a content without v...

Has anyone done a performance analysis of boost::asio ?

I require socket-like local IPC. I used named pipes and overlapped IO on windows and I want to rewrite the application to boost::ASIO so that it can use UNIX domain sockets as well. I've recently reviewed parts of the libevent library and I know it only supports socket() and select() for windows in the 1.4 version. As overlapped IO is v...

Is it possible to use separate threads for reading and writing with Boost.Asio?

According to the Boost Documentation, having multiple threads call io_service::run() sets up a pool of threads that the IO service can use for performing asynchronous tasks. It explicitly states that all threads that have joined the pool are considered equivalent. Does this imply that it is not possible to have a separate thread for rea...

boost.asio tcp sockets, Will asynchronous operations be ordered?

Hi all, If am am calling boost::asio::async_write/async_read directly after each other, will the data be ordered? Or do I need to wait on the callback before I am calling write/read again? Thanks in advance! ...

Interrupt boost::asio synchronous read?

I'm using asio synchronous sockets to read data over TCP from a background thread. This is encapsulated in a "server" class. However, I want the thread to exit when the destructor of this class is called. The problem is that a call to any of the read functions does block, so the thread cannot be easily terminated. In Win32 there is an A...

boost::asio multi-threading problem

Ive got a server that uses boost::asio which I wish to make multi-threaded. The server can be broken down into several "areas", with the sockets starting in a connect area, then once connected to a client being moved to a authentication area (i.e. login or register) before then moving between various other parts of the server depedning ...

Boost Asio and Web Sockets?

Does anyone know of any attempt to implement the Web Sockets API using Boost asio? ...

How do I convert a boost::asio::streambuf into a std::string?

I would like to convert a boost::asio::streambuf into a std::string. How do I do that easily? ...

Why this simple Boost::asio program doesn't work as expected?

I wrote this: #include <vector> #include <iostream> #include <sstream> #include <boost/asio.hpp> #include <tr1/memory> #include <boost/bind.hpp> #include <stdint.h> using namespace boost::asio; using namespace boost::asio::ip; class tcpServer{ public: class connection{ tcp::socket socketConnection; enum {CONNE...

How do I find out if there is data available to be read from a socket in boost::asio?

I'm using the Boost ASIO library to write a TCP client program. The protocol starts with a banner line when you connect followed by '\r\n' I can send commands at any time much like smtp. However, the server can also send me data when I don't ask for it and it's terminated with a '\r\n' I have a line like to this to read and parse the ...

Asio async and concurrency

Hello, I'm writing some code with boost asio, using asynchronous tcp connections. I've to admit that I have some doubts about it. All these regard concurrency. Here are some: What happens if I start two or more async_write on the same socket without waiting completion of the first one? Will the handlers (and the async_write) overlap o...

Better boost asio deadline_timer example

I'm after a better example of the boost::asio::deadline_timer The examples given will always time out and call the close method. I tried calling cancel() on a timer but that causes the function passed into async_wait to be called immediately. Whats the correct way working with timers in a async tcp client? ...

dedicated thread for io_service::run()

I want to provide a global io_service that is driven by one global thread. Simple enough, I just have the thread body call io_service::run(). However, that doesn't work as run (run_one, poll, poll_one) return if there is no work to do. But, if the thread repeatedly calls run(), it will busy loop when there is nothing to do. I'm looki...

Need help on asynchrous non-blocking file loading with boost::asio and boost::iostreams ( or something different? )

I'm coding in c++, and I'm trying to load an image file asynchronously. After some research, I found some mentions about using boost::asio and boost::iostreams to do it. However, the documentation and example for boost::asio is mostly socket related, so it doesn't help me much. Here is what I need: Load a file asynchronously and upon ...

general boost asio stream reads question

I'm a little confused about how reading data into a stream works in asio. My main questions are: What happens if there are multiple asynchronous writes from one computer going on at the same time, and only one asynchronous read on the receiving computer. Over a TCP protocol, is there any chance that the data will get interleaved? How ...

boost::asio cleanly disconnecting

Sometimes boost::asio seems to disconnect before I want it to, i.e. before the server properly handles the disconnect. I'm not sure how this is possible because the client seems to think its fully sent the message, yet when the server emits the error its not even read the message header... During testing this only happens maybe 1 in 5 ti...

help with async_read_until

I'm having trouble implmenting the 3rd parameter in the function documented here: http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/async_read_until/overload4.html What I'd like to be able to do is use the callback on the 3rd parameter of async_read_until to detect when a complete chunk has arrived. My packets have the f...

Writing a filter for incoming connections

I'm using C++/boost::asio under Win7. I'm trying to "sniff" trafic over a given TCP/IP port. Hence, I'd like to listen on that port, receive messages, analyze them, but also immidately allow them to flow further, as if I never intercepted them. I want them to sink into the program that normally listens and connects on that port. Imagine...

Linker error when compiling boost.asio example

I am trying to compile a boost.asio example, but I get the following linker errors: "undefined reference to _Unwind_Resume'" and "undefined reference to__gxx_personality_v0'". I've been searching google for a long time, but nothing helped. Which library do I need to link? Thanks in advance! ...