本文整理汇总了C++中tcp::resolver::iterator::host_name方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::host_name方法的具体用法?C++ iterator::host_name怎么用?C++ iterator::host_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcp::resolver::iterator
的用法示例。
在下文中一共展示了iterator::host_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void session::on_http2_connect_server(const boost::system::error_code& error, tcp::resolver::iterator endpoint_iterator)
{
if (error)
{
BOOST_LOG_TRIVIAL(debug) << "[" << session_id << "] " << error.message();
BOOST_LOG_TRIVIAL(error) << "[" << session_id << "] open " << endpoint_iterator->host_name() << " fail";
stop();
return;
}
BOOST_LOG_TRIVIAL(debug) << "[" << session_id << "] open " << endpoint_iterator->host_name();
std::string ack = "HTTP/1.1 200 Connection Established\r\n\r\n";
write_to_client(ack.c_str(), ack.size(), true);
boost::asio::streambuf::mutable_buffers_type buf = read_client_buf.prepare(SOCKET_RECV_BUF_LEN);
client_socket.async_read_some(buf,
strand_.wrap(
boost::bind(&session::on_read_client_data, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
)
);
server_socket.async_read_some(boost::asio::buffer(server_buf, SOCKET_RECV_BUF_LEN),
strand_.wrap(boost::bind(&session::on_read_server_data, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)
)
);
}
示例2: connect_handler
void EthStratumClient::connect_handler(const boost::system::error_code& ec, tcp::resolver::iterator i)
{
dev::setThreadName("stratum");
if (!ec)
{
m_connected = true;
cnote << "Connected to stratum server " << i->host_name() << ":" << p_active->port;
if (!p_farm->isMining())
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu");
else if (m_minerType == MinerType::CL)
p_farm->start("opencl");
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda");
}
std::ostream os(&m_requestBuffer);
os << "{\"id\": 1, \"method\": \"mining.subscribe\", \"params\": []}\n";
async_write(m_socket, m_requestBuffer,
boost::bind(&EthStratumClient::handleResponse, this,
boost::asio::placeholders::error));
}
else
{
cwarn << "Could not connect to stratum server " << p_active->host << ":" << p_active->port << ", " << ec.message();
reconnect();
}
}
示例3: connect_handler
void EthStratumClient::connect_handler(const boost::system::error_code& ec, tcp::resolver::iterator i)
{
dev::setThreadName("stratum");
if (!ec)
{
m_connected = true;
cnote << "Connected to stratum server " << i->host_name() << ":" << p_active->port;
if (!p_farm->isMining())
{
cnote << "Starting farm";
if (m_minerType == MinerType::CPU)
p_farm->start("cpu", false);
else if (m_minerType == MinerType::CL)
p_farm->start("opencl", false);
else if (m_minerType == MinerType::CUDA)
p_farm->start("cuda", false);
else if (m_minerType == MinerType::Mixed) {
p_farm->start("cuda", false);
p_farm->start("opencl", true);
}
}
std::ostream os(&m_requestBuffer);
string user;
size_t p;
switch (m_protocol) {
case STRATUM_PROTOCOL_STRATUM:
os << "{\"id\": 1, \"method\": \"mining.subscribe\", \"params\": []}\n";
break;
case STRATUM_PROTOCOL_ETHPROXY:
p = p_active->user.find_first_of(".");
user = p_active->user.substr(0, p);
if (p + 1 <= p_active->user.length())
m_worker = p_active->user.substr(p + 1);
else
m_worker = "";
if (m_email.empty())
{
os << "{\"id\": 1, \"worker\":\"" << m_worker << "\", \"method\": \"eth_submitLogin\", \"params\": [\"" << user << "\"]}\n";
}
else
{
os << "{\"id\": 1, \"worker\":\"" << m_worker << "\", \"method\": \"eth_submitLogin\", \"params\": [\"" << user << "\", \"" << m_email << "\"]}\n";
}
break;
case STRATUM_PROTOCOL_ETHEREUMSTRATUM:
os << "{\"id\": 1, \"method\": \"mining.subscribe\", \"params\": [\"ethminer/" << ETH_PROJECT_VERSION << "\",\"EthereumStratum/1.0.0\"]}\n";
break;
}
async_write(m_socket, m_requestBuffer,
boost::bind(&EthStratumClient::handleResponse, this,
boost::asio::placeholders::error));
}
else
{
cwarn << "Could not connect to stratum server " << p_active->host << ":" << p_active->port << ", " << ec.message();
reconnect();
}
}