本文整理汇总了C++中tcp::socket::write_some方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::write_some方法的具体用法?C++ socket::write_some怎么用?C++ socket::write_some使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcp::socket
的用法示例。
在下文中一共展示了socket::write_some方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delivery
void delivery()
{
std::vector<char> buf(BUFF_SIZE);
while(src_sock.available()){
src_sock.read_some(boost::asio::buffer(buf));
dest_sock.write_some(boost::asio::buffer(buf));
}
while(dest_sock.available()){
dest_sock.read_some(boost::asio::buffer(buf));
src_sock.write_some(boost::asio::buffer(buf));
}
return;
}
示例2: sendQueuedMessages
void TcpBase::sendQueuedMessages(tcp::socket& s) {
mutex::scoped_lock lock(mutex_);
while (!outQueue_.empty()) {
std::string message = outQueue_.front();
boost::system::error_code error;
s.write_some(boost::asio::buffer(message.data(), message.size()), error);
if (error) {
throw boost::system::system_error(error);
}
logTrace("TX: " + message);
outQueue_.pop();
}
}
示例3: textRequest
boost::system::error_code sendRequest(tcp::socket & socket, uint32_t sequence, Words words)
{
boost::system::error_code error;
TextRconPacket textRequest(false, false, sequence, words);
BinaryRconPacket binaryRequest(textRequest);
const uint8_t* requestData;
unsigned int requestLength;
binaryRequest.getBuffer(requestData, requestLength);
socket.write_some(boost::asio::buffer(reinterpret_cast<const char*>(requestData), requestLength), error);
return error;
}