本文整理汇总了C++中SocketPtr::set_option方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketPtr::set_option方法的具体用法?C++ SocketPtr::set_option怎么用?C++ SocketPtr::set_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketPtr
的用法示例。
在下文中一共展示了SocketPtr::set_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: downloadAllBinFiles
void Downloader::downloadAllBinFiles(const std::string& guid, Parser* parser)
{
std::string host = extractHost(parser->getSoapInfo().collectionRoot);
SocketPtr sock = connect(host);
boost::asio::socket_base::keep_alive keepAlive(true);
sock->set_option(keepAlive);
std::stringstream headers;
std::vector<std::string> filenames;
int nbCoorSystem = parser->getNbCoordSystem();
for (unsigned int i=0; i<parser->getNbCoordSystem(); ++i)
{
int nbPointCloud = parser->getNbPointCloud(i);
for (unsigned int j=0; j<parser->getNbPointCloud(i); ++j)
{
std::stringstream filename;
filename << "bin/points_"<< i << "_" << j << ".bin";
if (!bf::exists(Parser::createFilePath(guid, filename.str())))
{
filenames.push_back(filename.str());
std::stringstream url;
url << parser->getSoapInfo().collectionRoot << filename.str().substr(4);
headers << createGETHeader(removeHost(url.str(), host), host);
}
}
}
if (filenames.size() > 0)
{
//send GET request
boost::system::error_code error;
boost::asio::write(*sock, boost::asio::buffer(headers.str().c_str()), boost::asio::transfer_all(), error);
//read the response (header + content)
boost::asio::streambuf response;
while (boost::asio::read(*sock, response, boost::asio::transfer_at_least(1), error));
//read all response header and content
std::istream response_stream(&response);
for (unsigned int i=0; i<filenames.size(); ++i)
{
int length = getContentLength(response_stream);
saveBinFile(Parser::createFilePath(guid, filenames[i]), response_stream, length);
}
}
sock->close();
}