boost-asio

How copy or reuse boost::asio::streambuf?

丶灬走出姿态 提交于 2019-12-05 14:24:44
I'm implementing http proxy server with some business logic on boost asio. In point (1) boost::asio::streambuf response_ contains http headers and part of http body. After parsing with http_response::parse buffer boost::asio::streambuf response_ is empty. At (2) i check all business logic and read body if there was Content-Length header in headers. Then if response_ data fits specific condtions i want to send the original response_ buffer to another socket (3). The problem is that buffer is empty after parsing. Is there a way to copy boost::asio::streambuf to reuse data? void http_response:

SSL_use_certificate seems to be causing a double free

▼魔方 西西 提交于 2019-12-05 12:35:26
Some Context I'm writing a transparent/intercepting, HTTPS capable proxy in C++ using openSSL. I'm redirecting traffic through my proxy using WinDivert. For my SSL initialization, my HTTPSAcceptor generates a temporary EC_KEY for the entire server context for the handshake operation. I keep an in-memory "store" (Not an actual X509_STORE object) where I spoof and store certificates using host/SAN DNS entries as the lookup keys. As a side note, this is the first time I've ever worked with openSSL so please correct and pardon any ignorance in my approach. :) Also pardon the excessive abuse of

Boost ASIO: SSL handshake() never finishes

南笙酒味 提交于 2019-12-05 12:30:50
问题 I have a C++ client app that uses Boost ASIO to make SSL connections to various servers. But against 2 specific servers, the SSL connection cannot be established. It hangs in the call to boost::asio::ssl::stream::handshake() . I've used Wireshark to observe the conversation between client and server. A working SSL connection seems to do this: sslsocket.lowest_layer().connect( endpoint, ec ); C -> SYN -> S C <- SYN ACK <- S C -> ACK -> S sslsocket.handshake( SSLSocket::client, ec ); C -> 209

How to specify a specific NIC to be used in an application written in c++ (boost asio)

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:02:56
I have a machine connected to multiple independent networks, each on a different NIC (Network Interface Card). The machine runs Windows 7. I run an application on the machine which needs to connect to a specific IP through a specific NIC, using TCP. The application uses c++11 and boost asio (1.53.0) for networking, and the source can be changed. What are the different reasonable ways to solve this problem (specify endpoint IP and NIC) in a Windows environment? The current solution assigns the respective (blocks of) IPs to the right NIC in the the routing table - by using the command line

Interrupt boost::asio synchronous read?

佐手、 提交于 2019-12-05 08:21:13
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 API for that: WaitForMultipleObjects which would do exactly what I want. How would I achieve a similar effect with boost? In our application, we set the "terminating" condition, and then use a self-connection to the port that the thread is listening on so it

Should I be seeing significant differences between std::bind and boost::bind?

无人久伴 提交于 2019-12-05 08:08:55
I'm exploring the support for C++11 on the g++-4.7 (Ubuntu/Linaro 4.7.3-2ubuntu~12.04, to be specific) and I seem to be finding differences. In particular, if I comment out #include <boost/bind.hpp> and systematically replace occurrences of boost::bind with std::bind in the Boost ASIO async client example (taken from http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/http/client/async_client.cpp ), the program no longer compiles. Any explanation for this? #include <functional> namespace boost { namespace asio { namespace stdplaceholders { static decltype ( :: std :: placeholders

Boost ASIO socket read N bytes not more not less and wait until they come or timeout exception?

坚强是说给别人听的谎言 提交于 2019-12-05 07:53:09
Creating a simple TCP server based on examples but still do not get how to create a socket that would read some amount of bytes and if there will not be enough would wait. I need this to be NOT asynchronous operation. #include <iostream> #include <boost/asio.hpp> #ifdef _WIN32 #include "Windows.h" #endif using namespace boost::asio::ip; using namespace std; int main(){ int m_nPort = 12345; boost::asio::io_service io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), m_nPort)); cout << "Waiting for connection..." << endl; tcp::socket socket(io_service); acceptor.accept(socket)

Boost asio - multiple client connections to different servers

邮差的信 提交于 2019-12-05 07:28:21
I am trying to evaluate using async boost udp/tcp socket operations vs synchronous for my application. I have been trying to find an example that is similar to my design but did not find anything which led me to believe I might be trying to fit async ops into my design even though it is not the right path. I want to connect to multiple (read: between 1-10) servers and communicate with them using different protocols; I have 4-5 threads which are producing data that needs to be communicated to any one of these server connections. My current design is synchronous and uses an io_service object per

Socket I/O mode epoll,overlapped I/O

隐身守侯 提交于 2019-12-05 07:00:20
问题 I am working client server application where I need to manage multiple socket connection 1000+. By exploration I found out the Overlapped I/O or Completion Port is nice to do de-multiplexing multiple socket in Windows and epoll is nice on Linux. Is epoll is different from Overlapped I/O or Completion Port in windows. I wanted to use boost since it works on both windows and Linux. Is it possible to implement these techniques (epoll and Overlapped I/O or Completion Port) using boost? 回答1: The

Boost.Asio socket destructor closes connection?

百般思念 提交于 2019-12-05 06:28:09
What exactly does the destructor of boost::asio::ip::tcp::socket do? I can't tell, even after scouring Boost docs and source code, if I need to use socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both); socket->close(); before calling delete socket; Do I need to close the socket manually, or does the destructor handle this? When a socket is destroyed, it will be closed as-if by socket.close(ec) during the destruction of the socket. I/O objects, such as socket , derive from basic_io_object . Within the basic_io_object destructor , destroy() will be invoked on the I/O object's I/O