25 #include "../face.hpp" 35 : m_unixSocket(unixSocket)
42 UnixTransport::getSocketNameFromUri(
const std::string& uriString)
45 std::string path =
"/var/run/nfd.sock";
47 if (uriString.empty()) {
55 BOOST_THROW_EXCEPTION(
Error(
"Cannot create UnixTransport from \"" +
64 BOOST_THROW_EXCEPTION(
Error(error.what()));
70 shared_ptr<UnixTransport>
73 return make_shared<UnixTransport>(getSocketNameFromUri(uri));
82 if (m_impl ==
nullptr) {
85 m_impl = make_shared<Impl>(ref(*
this), ref(ioService));
88 m_impl->connect(boost::asio::local::stream_protocol::endpoint(m_unixSocket));
94 BOOST_ASSERT(m_impl !=
nullptr);
101 BOOST_ASSERT(m_impl !=
nullptr);
102 m_impl->send(header, payload);
108 BOOST_ASSERT(m_impl !=
nullptr);
117 if (m_impl !=
nullptr) {
126 BOOST_ASSERT(m_impl !=
nullptr);
a transport using Unix stream socket
Copyright (c) 2013-2017 Regents of the University of California.
Represents a TLV element of NDN packet format.
#define NDN_LOG_DEBUG(expression)
log at DEBUG level
#define NDN_LOG_INIT(name)
declare a log module
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.
void pause() override
pause the transport
void resume() override
resume the transport
~UnixTransport() override
void close() override
Close the connection.
represents the underlying protocol and address used by a Face
const std::string & getScheme() const
get scheme (protocol)
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
const std::string & getPath() const
get path