tools: fix compilation with Boost 1.67
Change-Id: I0f4bae23f26eca07044990ce6dd01da750cfb569
Refs: #4584
diff --git a/src/net/asio-fwd.hpp b/src/net/asio-fwd.hpp
index bda6b83..fb80ee5 100644
--- a/src/net/asio-fwd.hpp
+++ b/src/net/asio-fwd.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,24 +24,17 @@
#include <boost/version.hpp>
+namespace boost {
+namespace asio {
+
#if BOOST_VERSION >= 106600
-
-#include <boost/asio/ts/netfwd.hpp>
-
-namespace boost {
-namespace asio {
+class io_context;
using io_service = io_context;
-} // namespace asio
-} // namespace boost
-
#else
-
-namespace boost {
-namespace asio {
class io_service;
+#endif // BOOST_VERSION >= 106600
+
} // namespace asio
} // namespace boost
-#endif // BOOST_VERSION >= 106600
-
#endif // NDN_NET_ASIO_FWD_HPP
diff --git a/tools/ndnsec/cert-dump.cpp b/tools/ndnsec/cert-dump.cpp
index e0b99b4..39d5baf 100644
--- a/tools/ndnsec/cert-dump.cpp
+++ b/tools/ndnsec/cert-dump.cpp
@@ -22,7 +22,9 @@
#include "ndnsec.hpp"
#include "util.hpp"
+#if BOOST_VERSION < 106700
#include <boost/date_time/posix_time/posix_time_duration.hpp>
+#endif // BOOST_VERSION < 106700
namespace ndn {
namespace ndnsec {
@@ -173,9 +175,12 @@
return 0;
}
if (isRepoOut) {
- using namespace boost::asio::ip;
- tcp::iostream requestStream;
+ boost::asio::ip::tcp::iostream requestStream;
+#if BOOST_VERSION >= 106700
+ requestStream.expires_after(std::chrono::seconds(3));
+#else
requestStream.expires_from_now(boost::posix_time::seconds(3));
+#endif // BOOST_VERSION >= 106700
requestStream.connect(repoHost, repoPort);
if (!requestStream) {
std::cerr << "fail to open the stream!" << std::endl;
diff --git a/tools/ndnsec/cert-install.cpp b/tools/ndnsec/cert-install.cpp
index e83f41b..3ae6724 100644
--- a/tools/ndnsec/cert-install.cpp
+++ b/tools/ndnsec/cert-install.cpp
@@ -22,7 +22,9 @@
#include "ndnsec.hpp"
#include "util.hpp"
+#if BOOST_VERSION < 106700
#include <boost/date_time/posix_time/posix_time_duration.hpp>
+#endif // BOOST_VERSION < 106700
namespace ndn {
namespace ndnsec {
@@ -40,14 +42,18 @@
security::v2::Certificate
getCertificateHttp(const std::string& host, const std::string& port, const std::string& path)
{
- using namespace boost::asio::ip;
-
- tcp::iostream requestStream;
+ boost::asio::ip::tcp::iostream requestStream;
+#if BOOST_VERSION >= 106700
+ requestStream.expires_after(std::chrono::seconds(3));
+#else
requestStream.expires_from_now(boost::posix_time::seconds(3));
+#endif // BOOST_VERSION >= 106700
+
requestStream.connect(host, port);
if (!requestStream) {
BOOST_THROW_EXCEPTION(HttpException("HTTP connection error"));
}
+
requestStream << "GET " << path << " HTTP/1.0\r\n";
requestStream << "Host: " << host << "\r\n";
requestStream << "Accept: */*\r\n";