本文整理汇总了C++中utils::to_string_ss方法的典型用法代码示例。如果您正苦于以下问题:C++ utils::to_string_ss方法的具体用法?C++ utils::to_string_ss怎么用?C++ utils::to_string_ss使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::to_string_ss方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeviceError
MAVConnTCPClient::MAVConnTCPClient(uint8_t system_id, uint8_t component_id,
std::string server_host, unsigned short server_port) :
MAVConnInterface(system_id, component_id),
tx_in_progress(false),
tx_q {},
rx_buf {},
io_service(),
io_work(new io_service::work(io_service)),
socket(io_service)
{
if (!resolve_address_tcp(io_service, conn_id, server_host, server_port, server_ep))
throw DeviceError("tcp: resolve", "Bind address resolve failed");
logInform(PFXd "Server address: %s", conn_id, to_string_ss(server_ep).c_str());
try {
socket.open(tcp::v4());
socket.connect(server_ep);
}
catch (boost::system::system_error &err) {
throw DeviceError("tcp", err);
}
// give some work to io_service before start
io_service.post(std::bind(&MAVConnTCPClient::do_recv, this));
// run io_service for async io
io_thread = std::thread([this] () {
utils::set_this_thread_name("mtcp%zu", conn_id);
io_service.run();
});
}
示例2: client_connected
void MAVConnTCPClient::client_connected(size_t server_channel)
{
logInform(PFXd "Got client, id: %zu, address: %s",
server_channel, conn_id, to_string_ss(server_ep).c_str());
// start recv
socket.get_io_service().post(std::bind(&MAVConnTCPClient::do_recv, this));
}
示例3: client_closed
void MAVConnTCPServer::client_closed(std::weak_ptr<MAVConnTCPClient> weak_instp)
{
if (auto instp = weak_instp.lock()) {
bool locked = mutex.try_lock();
logInform(PFXd "Client connection closed, id: %p, address: %s",
conn_id, instp.get(), to_string_ss(instp->server_ep).c_str());
client_list.remove(instp);
if (locked)
mutex.unlock();
}
}
示例4: resolve_address_tcp
static bool resolve_address_tcp(io_service &io, size_t chan, std::string host, unsigned short port, tcp::endpoint &ep)
{
bool result = false;
tcp::resolver resolver(io);
error_code ec;
tcp::resolver::query query(host, "");
std::for_each(resolver.resolve(query, ec), tcp::resolver::iterator(),
[&](const tcp::endpoint & q_ep) {
ep = q_ep;
ep.port(port);
result = true;
logDebug(PFXd "host %s resolved as %s", chan, host.c_str(), to_string_ss(ep).c_str());
});
if (ec) {
logWarn(PFXd "resolve error: %s", chan, ec.message().c_str());
result = false;
}
return result;
}