Added Transport close method
diff --git a/ndn-cpp/transport/TcpTransport.cpp b/ndn-cpp/transport/TcpTransport.cpp
index a6a6663..bf5180a 100644
--- a/ndn-cpp/transport/TcpTransport.cpp
+++ b/ndn-cpp/transport/TcpTransport.cpp
@@ -51,4 +51,11 @@
}
}
+void TcpTransport::close()
+{
+ ndn_Error error;
+ if (error = ndn_TcpTransport_close(&transport_))
+ throw std::runtime_error(ndn_getErrorString(error));
+}
+
}
diff --git a/ndn-cpp/transport/TcpTransport.hpp b/ndn-cpp/transport/TcpTransport.hpp
index 88e61fb..da8b103 100644
--- a/ndn-cpp/transport/TcpTransport.hpp
+++ b/ndn-cpp/transport/TcpTransport.hpp
@@ -29,6 +29,8 @@
virtual void send(const unsigned char *data, unsigned int dataLength);
virtual void tempReceive();
+
+ virtual void close();
private:
struct ndn_TcpTransport transport_;
diff --git a/ndn-cpp/transport/Transport.cpp b/ndn-cpp/transport/Transport.cpp
index e0aab03..1e63649 100644
--- a/ndn-cpp/transport/Transport.cpp
+++ b/ndn-cpp/transport/Transport.cpp
@@ -19,5 +19,9 @@
{
throw logic_error("unimplemented");
}
+
+void Transport::close()
+{
+}
}
diff --git a/ndn-cpp/transport/Transport.hpp b/ndn-cpp/transport/Transport.hpp
index af1a2c0..dedfffd 100644
--- a/ndn-cpp/transport/Transport.hpp
+++ b/ndn-cpp/transport/Transport.hpp
@@ -25,6 +25,11 @@
{
send(&data[0], data.size());
}
+
+ /**
+ * Close the connection. This base class implementation does nothing, but your derived class can override.
+ */
+ virtual void close();
};
}
diff --git a/ndn-cpp/transport/UdpTransport.cpp b/ndn-cpp/transport/UdpTransport.cpp
index 52b62a5..5fc4a71 100644
--- a/ndn-cpp/transport/UdpTransport.cpp
+++ b/ndn-cpp/transport/UdpTransport.cpp
@@ -51,4 +51,11 @@
}
}
+void UdpTransport::close()
+{
+ ndn_Error error;
+ if (error = ndn_UdpTransport_close(&transport_))
+ throw std::runtime_error(ndn_getErrorString(error));
+}
+
}
diff --git a/ndn-cpp/transport/UdpTransport.hpp b/ndn-cpp/transport/UdpTransport.hpp
index 781effd..9043e5c 100644
--- a/ndn-cpp/transport/UdpTransport.hpp
+++ b/ndn-cpp/transport/UdpTransport.hpp
@@ -30,6 +30,8 @@
virtual void tempReceive();
+ virtual void close();
+
private:
struct ndn_UdpTransport transport_;
Face *face_;