35 : m_unixSocket(unixSocket)
42 UnixTransport::getSocketNameFromUri(
const std::string& uriString)
46 std::string path =
"/run/nfd.sock";
48 std::string path =
"/var/run/nfd.sock";
51 if (uriString.empty()) {
56 const FaceUri uri(uriString);
58 if (uri.getScheme() !=
"unix") {
59 NDN_THROW(Error(
"Cannot create UnixTransport from \"" + uri.getScheme() +
"\" URI"));
62 if (!uri.getPath().empty()) {
66 catch (
const FaceUri::Error& error) {
73 shared_ptr<UnixTransport>
76 return make_shared<UnixTransport>(getSocketNameFromUri(uri));
84 if (m_impl ==
nullptr) {
86 m_impl = make_shared<Impl>(*
this, ioService);
89 m_impl->connect(boost::asio::local::stream_protocol::endpoint(m_unixSocket));
95 BOOST_ASSERT(m_impl !=
nullptr);
102 BOOST_ASSERT(m_impl !=
nullptr);
111 if (m_impl !=
nullptr) {
120 BOOST_ASSERT(m_impl !=
nullptr);
Represents a TLV element of the NDN packet format.
std::function< void(const Block &)> ReceiveCallback
virtual void connect(boost::asio::io_service &ioService, ReceiveCallback receiveCallback)
Asynchronously open the connection.
A transport using Unix stream socket.
void resume() override
Resume the transport.
static shared_ptr< UnixTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
void pause() override
Pause the transport, canceling all pending operations.
void send(const Block &wire) override
Send a TLV block through the transport.
~UnixTransport() override
void connect(boost::asio::io_service &ioService, ReceiveCallback receiveCallback) override
Asynchronously open the connection.
UnixTransport(const std::string &unixSocket)
void close() override
Close the connection.
#define NDN_THROW_NESTED(e)
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.