本文整理汇总了C++中ip::tcp::socket::write_some方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::write_some方法的具体用法?C++ socket::write_some怎么用?C++ socket::write_some使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ip::tcp::socket
的用法示例。
在下文中一共展示了socket::write_some方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_coin
void c_netuser::send_coin(ip::tcp::socket &socket_, const std::string &coin_data) {
DBG_MTX(dbg_mtx, "START");
assert(socket_.is_open());
boost::system::error_code ec;
char header[2] = {'$', 't'};
socket_.write_some(buffer(header, 2), ec);
uint32_t coin_data_size = coin_data.size();
socket_.write_some(buffer(&coin_data_size, 4), ec);
socket_.write_some(buffer(coin_data), ec);
}
示例2: send_public_key_resp
void c_netuser::send_public_key_resp(ip::tcp::socket &socket_) {
DBG_MTX(dbg_mtx, "START");
assert(socket_.is_open());
boost::system::error_code ec;
char header[2] = {'p', 'k'};
DBG_MTX(dbg_mtx, "send header");
socket_.write_some(buffer(header, 2), ec);
//uint32_t packet_size = ed25519_sizes::pub_key_size;
ed_key packet = get_public_key();
uint32_t packet_size = packet.size();
// TODO send binary data
DBG_MTX(dbg_mtx,"send public key size" << "[" << packet_size << "]");
socket_.write_some(boost::asio::buffer(&packet_size, 4), ec);
DBG_MTX(dbg_mtx,"send public key data" << "[" << packet << "]");
socket_.write_some(boost::asio::buffer(packet.c_str(), packet_size), ec);
DBG_MTX(dbg_mtx,"end of sending public key");
}
示例3: send_public_key_req
void c_netuser::send_public_key_req(ip::tcp::socket &socket_) {
DBG_MTX(dbg_mtx, "send public key request");
assert(socket_.is_open());
boost::system::error_code ec;
char pubkey_send_req[2] = {'p','k'};
size_t sendbytes = socket_.write_some(boost::asio::buffer(pubkey_send_req, request_type_size),ec);
DBG_MTX(dbg_mtx, "pk: " << sendbytes << ":[" << pubkey_send_req[0] << pubkey_send_req[1] << "]");
}