Все вопросы: [boost-asio]
71 вопросов
Boost: как указать «любой порт» для TCP-сервера?
Как я могу указать «выбрать любой доступный порт» для TCP-сервера в Boost? И как мне получить порт, когда соединение принято? ОБНОВЛЕНО: Под "доступным портом" я подразумеваю: ОС может выбрать любой доступный порт, т.е. я не хочу указывать порт.
Ускорение asio udp waitForReadyRead
Я пытаюсь реализовать функцию с помощью boost asio udpSocket, которая ожидает, пока данные будут готовы к чтению, или ожидает, пока истечет время ожидания. Используя asyc_read и async_wait, я могу сделать что-то подобное, но мне нужно прочитать данные.Я хотел бы сделать то же самое без чтен...
Проблема с библиотеками, использующими winsock.h
У меня есть проект, в котором используются Boost.Asio и Media-Decoding-Samples, которые поставляются с Intel IPP-Library.Проблема в следующем.Если я скомпилирую проект без определения WIN32_LEAN_AND_MEAN, Asio выдаст печально известную ошибку «winsock.h already included».Если я определю макрос, ...
Документация Boost.Asio не существует.Что означают эти ошибки?
Я борюсь с двумя ошибками с Boost.Asio. Первое происходит, когда я пытаюсь получить данные через сокет: char reply[1024]; boost::system::error_code error; size_t reply_length = s.receive(boost::asio::buffer(reply, 1024), 0, error); if (error) cout << error.message() << endl; //...
Как создать сокет Boost.Asio из собственного сокета?
Я просто пытаюсь создать усиление ip::tcp::socket из существующего собственного сокета.В функции assign ,первый параметр должен быть «protocol_type», а второй должен быть «native_type», но он никогда не объясняет, что это такое, и не дает пример его использования. Я предполагаю, что вторым д...
boost asio: ведение списка подключенных клиентов
Я ищу лучший способ изменить Boost Asio пример HTTP Server 3 для ведения списка подключенных в данный момент клиентов. Если я изменю server.hpp из примера как: class server : private boost::noncopyable { public: typedef std::vector< connection_ptr > ConnectionList; // ... ...
Boost Asio async_read не перестает читать?
Итак, Я экспериментировал с функциями и сокетами Boost asio (особенно с асинхронным чтением / записью). Теперь я подумал, что boost::asio::async_read вызывает обработчик только тогда, когда новый буфер поступает из сетевого соединения ... однако он не прекращает чтение того же буфера и, таким...
Можно ли обернуть бустерные розетки Pimpl?
в проекте мы хотим обернуть сокет Boost Asio таким образом, чтобы класс using или обертка .h не включали заголовки boost. Обычно мы используем указатели и опережающие объявления для обернутых классов. Заявление Фоварда: namespace boost { namespace asio { namespace ip { ...
C++, boost asio, receive null terminated string
How can I retrieve null-terminated string from a socket using the boost::asio library?
How to resolve host (only) using Boost.Asio?
According to the documentation of boost::asio::ip::tcp::resolver::query in order to resolve host it should receive service as well. What if I want to resolve host without relation to port? How should I do it at all? Should I specify dummy port?
boost::asio::ip::tcp::socket is connected?
I want to verify the connection status before performing read/write operations. Is there a way to make an isConnect() method? I saw this, but it seems "ugly". I have tested is_open() function as well, but it doesn't have the expected behavior.
Linking Boost Library in Linux
I am trying to build a project using Boost's Asio and I am having some trouble. Initially, I tried to build the project without any additional libraries since everything is supposedly in the header files. The program I am trying to build looks like this: #include <iostream> #include <...
getting an error of "Service not found" in a async_resolve handler
I have code that looks like the following: //unrelated code snipped resolver.reset(new tcp::resolver(iosvc)); tcp::resolver::query query(host, port); resolver->async_resolve(query, boost::bind(&TCPTransport::handle_resolve, this, boost::asio::placeholders::error, boost::as...
Boost Threads and Timers, C++
I have this code for a custom class 'sau_timer': sau_timer::sau_timer(int secs, timerparam f, vector<string> params) : strnd(io), t(io, boost::posix_time::seconds(secs)) { assert(secs > 0); this->f = f; this->params = params; t.async_wait(strnd.wrap(boost::bin...
Boost.Asio iostream flush not working?
any ideas why stream.flush(); won't work? boost::asio::ip::tcp::iostream stream("localhost","5000"); assert(stream.good()); stream << 1; stream.flush(); while(true); it's only flushed if the loop is removed and the line boost::this_thread::sleep(boost::posix_time::seconds(1)); is exe...
boost::bind, boost::asio, boost::thread, and classes
sau_timer::sau_timer(int secs, timerparam f) : strnd(io), t(io, boost::posix_time::seconds(secs)) { assert(secs > 0); this->f = f; //t.async_wait(boost::bind(&sau_timer::exec, this, _1)); t.async_wait(strnd.wrap(boost::bind(&sau_timer::exec, this))); boost:...
boost asio example crashes on mac osx
I am trying to run blocking_udp_echo_server.cpp from Boost asio example on MacOSX 10.5. But it crashes: From the console: /Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h:127: error: attempt to copy-construct an iterator from a singular iterator. Objects involved ...
boost.asio, how to read a complete IP packet using asio
I would like to use a function which reads on a socket port, and gives back the control whenever an IP packet is received. the boost::asio::ip::udp::socket has a function receive (or async_receive) that returns how many bytes were read. the doc states: Receive some data on a connected socket. ...
Boost.Asio synchronous communication
I have a problem using asio. My client/server application requires only synchronous communication. So, using the examples for synchro from the boost homepage, I have set up two procedures to send and receive data. Their code is as follows: void vReceive(tcp::socket & socket, std::string &...
Is there an elegant way to bridge two devices/streams in Asio?
Given two stream-oriented I/O objects in Asio, what is the simplest way to forward data from one device to the other in both directions? Could this be done with boost::iostreams::combination or boost::iostreams:copy perhaps? Or is a manual approach better--waiting for data on each end and then wr...
About write buffer in general network programming
I'm writing server using boost.asio. I have read and write buffer for each connection and use asynchronized read/write function (async_write_some / async_read_some). With read buffer and async_read_some, there's no problem. Just invoking async_read_some function is okay because read buffer is re...
C++ Using windows named pipes
For some reason both the mast and slave fail, however I could find any good examples on how their meant to work, so im not sure where I went wrong. The master never exits the WaitForSingleObject after ConnectNamedPipe, and the slave throws an exception in the first boost::asio::read call, "Wait...
C++ Socket Server - Unable to saturate CPU
I've developed a mini HTTP server in C++, using boost::asio, and now I'm load testing it with multiple clients and I've been unable to get close to saturating the CPU. I'm testing on a Amazon EC2 instance, and getting about 50% usage of one cpu, 20% of another, and the remaining two are idle (ac...
Boost::Asio read/write operations
What is the difference between calling boost::asio::ip::tcp::socket's read_some/write_some member functions and calling the boost::asio::read/boost::asio::write free functions? More specifically: Is there any benefit to using one over the other? Why are both included in the library?
boost::asio, asynchronous read error
For some reason this results in an access violation, however not having any detailed documentation/help on this I'm not sure where I'm doing it wrong. Since going by what I've seen on the boost site this should be correct, and print the contents of each asio::write call from the client to a new ...
How should one tear down a boost::asio::ip::udp::socket?
I have read the boost asio reference, gone through the tutorial and looked at some of the examples. Still, I am unable to see how a socket should be torn down: Should I call close() or is this done by the socket's destructor? When should I call shutdown() What are the effects of shutdown()? I...
C++ mysql and boost asio header conflict
There seems to be a conflict with the windows headers between the mysql c-api and boost::asio. If I include mysql first I get: boost/asio/detail/socket_types.hpp(27) : fatal error C1189: #error : WinSock.h has already been included #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) # if de...
Boost asio async vs blocking reads, udp speed/quality
I have a quick and dirty proof of concept app that I wrote in C# that reads high data rate multicast UDP packets from the network. For various reasons the full implementation will be written in C++ and I am considering using boost asio. The C# version used a thread to receive the data using blo...
How should a HTTP server (using sockets) detect that the client is no longer connected and abort processing?
I'm implementing a basic HTTP Server in C++, using boost::asio. As I process each request, I write out the data in chunks, asychronously. If at any point I knew the client was no longer connected, I'd like to abort the processing, e.g. there's no point continuing to build results up to send out...
I have a server listening on sockets, whats a good approach to service CPU-bound requests with multiple threads?
I've got an application, written in C++, that uses boost::asio. It listens for requests on a socket, and for each request does some CPU-bound work (e.g. no disk or network i/o), and then responds with a response. This application will run on a multi-core system, so I plan to have (at least) 1 t...