SocketAdapter::SocketAdapter(MultiAdapter * pParent, CURLM * theCurlMultihandle) : boost_socket(pParent->io), readyState(0), read_in_progress(false), write_in_progress(false), _parent(pParent) { AC_DEBUG << "creating socket " << this; boost_socket.open(boost::asio::ip::tcp::v4()); boost::asio::ip::tcp::socket::non_blocking_io non_blocking_io(true); boost_socket.io_control(non_blocking_io); AC_TRACE << " socket is " << native(); };
void network_client::handle_handshake(const boost::system::error_code& error) { if (error) { last_error_ = error; connected_ = false; return; } boost::asio::ip::tcp::no_delay no_delay(true); boost::asio::socket_base::non_blocking_io non_blocking_io(true); ssl_socket_->lowest_layer().io_control(non_blocking_io); ssl_socket_->lowest_layer().set_option(no_delay); connected_ = true; post_read(); }
void network_client::handle_connect(const boost::system::error_code& error) { if (error) { last_error_ = error; connected_ = false; close(); return; } if (use_ssl_) { ssl_socket_->async_handshake(boost::asio::ssl::stream_base::client, boost::bind(&network_client::handle_handshake, this, boost::asio::placeholders::error)); } else { boost::asio::ip::tcp::no_delay no_delay(true); boost::asio::socket_base::non_blocking_io non_blocking_io(true); ssl_socket_->lowest_layer().io_control(non_blocking_io); ssl_socket_->lowest_layer().set_option(no_delay); connected_ = true; post_read(); } }