25 #include "../face.hpp"
31 : m_unixSocket(unixSocket)
40 UnixTransport::getSocketNameFromUri(
const std::string& uriString)
43 std::string path =
"/var/run/nfd.sock";
45 if (uriString.empty()) {
50 const util::FaceUri uri(uriString);
52 if (uri.getScheme() !=
"unix") {
53 BOOST_THROW_EXCEPTION(Error(
"Cannot create UnixTransport from \"" +
54 uri.getScheme() +
"\" URI"));
57 if (!uri.getPath().empty()) {
61 catch (
const util::FaceUri::Error& error) {
62 BOOST_THROW_EXCEPTION(Error(error.what()));
68 shared_ptr<UnixTransport>
71 return make_shared<UnixTransport>(getSocketNameFromUri(uri));
78 if (m_impl ==
nullptr) {
81 m_impl = make_shared<Impl>(ref(*
this), ref(ioService));
84 m_impl->connect(boost::asio::local::stream_protocol::endpoint(m_unixSocket));
90 BOOST_ASSERT(m_impl !=
nullptr);
97 BOOST_ASSERT(m_impl !=
nullptr);
98 m_impl->send(header, payload);
104 BOOST_ASSERT(m_impl !=
nullptr);
112 if (m_impl !=
nullptr) {
120 BOOST_ASSERT(m_impl !=
nullptr);
Copyright (c) 2013-2016 Regents of the University of California.
Class representing a wire element of NDN-TLV packet format.
virtual void send(const Block &wire) override
send a TLV block through the transport
static shared_ptr< UnixTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
virtual void pause() override
pause the transport
virtual void resume() override
resume the transport
virtual void close() override
Close the connection.
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback) override
asynchronously open the connection
UnixTransport(const std::string &unixSocket)
function< void(const Block &wire)> ReceiveCallback
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback)
asynchronously open the connection