boost-asio

Boost.Asio without Boost.System

為{幸葍}努か 提交于 2020-02-28 08:24:31
问题 On the Boost System page it is stated that: The Boost System Library is part of the C++11 Standard Library. But a number of Boost libraries, such as Asio, depend on Boost System. Is it possible to use the C++11 std stuff instead of Boost System to work with Asio? 回答1: AFAIR you can configure Boost System to be header-only Source: http://www.boost.org/doc/libs/1_66_0/libs/system/doc/reference.html Other than that, you might simply use Non-Boost Asio 来源: https://stackoverflow.com/questions

Protobuf, CodedInputStream parsing partial messages

随声附和 提交于 2020-02-22 08:44:08
问题 I'm trying to implement protobuf sending/receiving that's compatible with the java version, which includes a varint32-prefix first. I've almost got it working, but for some reason some messages become partial and fail an assert(). /receiver.cpp:69: void tcp_connection::handle_read_message(const boost::system::error_code&, size_t): Assertion `line.ParseFromCodedStream(&input)' failed. semder.pp boost::asio::streambuf buffer; std::ostream writer(&buffer); bool packet_full = false; uint32_t sent

Protobuf, CodedInputStream parsing partial messages

这一生的挚爱 提交于 2020-02-22 08:43:57
问题 I'm trying to implement protobuf sending/receiving that's compatible with the java version, which includes a varint32-prefix first. I've almost got it working, but for some reason some messages become partial and fail an assert(). /receiver.cpp:69: void tcp_connection::handle_read_message(const boost::system::error_code&, size_t): Assertion `line.ParseFromCodedStream(&input)' failed. semder.pp boost::asio::streambuf buffer; std::ostream writer(&buffer); bool packet_full = false; uint32_t sent

Protobuf, CodedInputStream parsing partial messages

一世执手 提交于 2020-02-22 08:43:50
问题 I'm trying to implement protobuf sending/receiving that's compatible with the java version, which includes a varint32-prefix first. I've almost got it working, but for some reason some messages become partial and fail an assert(). /receiver.cpp:69: void tcp_connection::handle_read_message(const boost::system::error_code&, size_t): Assertion `line.ParseFromCodedStream(&input)' failed. semder.pp boost::asio::streambuf buffer; std::ostream writer(&buffer); bool packet_full = false; uint32_t sent

boost thread pool

送分小仙女□ 提交于 2020-02-22 05:29:49
问题 I need a threadpool for my application, and I'd like to rely on standard (C++11 or boost) stuff as much as possible. I realize there is an unofficial(!) boost thread pool class, which basically solves what I need, however I'd rather avoid it because it is not in the boost library itself -- why is it still not in the core library after so many years? In some posts on this page and elsewhere, people suggested using boost::asio to achieve a threadpool like behavior. At first sight, that looked

boost thread pool

大兔子大兔子 提交于 2020-02-22 05:29:35
问题 I need a threadpool for my application, and I'd like to rely on standard (C++11 or boost) stuff as much as possible. I realize there is an unofficial(!) boost thread pool class, which basically solves what I need, however I'd rather avoid it because it is not in the boost library itself -- why is it still not in the core library after so many years? In some posts on this page and elsewhere, people suggested using boost::asio to achieve a threadpool like behavior. At first sight, that looked

Exception while receiving data from client - “End of file” error

青春壹個敷衍的年華 提交于 2020-02-07 08:25:29
问题 I am currently working on a client server TCP/IP application using Boost ASIO. The client sends data to the server using the following statement boost::system::error_code ignored_error; boost::asio::write(socket, boost::asio::buffer("Hello World\0"), ignored_error); The server reads this data as such (from an Asynch. read) boost::asio::async_read(*sock, boost::asio::buffer(buf_server),boost::bind(&ServerRead,boost::asio::placeholders::error)); Here is where the reading is done boost::array

Exception while receiving data from client - “End of file” error

ぃ、小莉子 提交于 2020-02-07 08:25:13
问题 I am currently working on a client server TCP/IP application using Boost ASIO. The client sends data to the server using the following statement boost::system::error_code ignored_error; boost::asio::write(socket, boost::asio::buffer("Hello World\0"), ignored_error); The server reads this data as such (from an Asynch. read) boost::asio::async_read(*sock, boost::asio::buffer(buf_server),boost::bind(&ServerRead,boost::asio::placeholders::error)); Here is where the reading is done boost::array

boost::asio::async_read_until not calling handler

 ̄綄美尐妖づ 提交于 2020-02-03 02:00:59
问题 I'm learning how to use Boost:asio library with Serial Port. I wrote some code using synchrous write and read and I now want to use asynchrous but it's not working. Simple Example: void readHandler(const boost::system::error_code&,std::size_t); streambuf buf; int main(int argc,char *argv[]){ io_service io; serial_port port(io,PORT); if(port.isopen()){ while(1){ // ... getting std::string::toSend from user ... write(port,buffer(toSend.c_str(),toSend.size())); async_read_until(port,buf,'\n'

Socket reusing with boost asio

那年仲夏 提交于 2020-01-30 05:15:35
问题 I try to use a boost asio socket, bound to a local address/port combination. That works great. What doesn't work, is the re-using of the socket once the socket and application has been stopped and restarted. // // open the socket - it would also be opened by the async_connect() // method but we might need an open socket to bind it _socket.open(boost::asio::ip::tcp::v4()); if ( _bindLocal ) { boost::asio::socket_base::reuse_address option(true); _socket.set_option(option); _socket.bind(