36 shared_ptr<TcpTransport>
40 return make_shared<TcpTransport>(hostAndPort.first, hostAndPort.second);
43 std::pair<std::string, std::string>
46 std::string host =
"localhost";
47 std::string port =
"6363";
49 if (uriString.empty()) {
56 const std::string scheme = uri.
getScheme();
57 if (scheme !=
"tcp" && scheme !=
"tcp4" && scheme !=
"tcp6") {
58 BOOST_THROW_EXCEPTION(
Error(
"Cannot create TcpTransport from \"" + scheme +
"\" URI"));
70 BOOST_THROW_EXCEPTION(
Error(error.what()));
80 if (m_impl ==
nullptr) {
83 m_impl = make_shared<Impl>(ref(*
this), ref(ioService));
86 boost::asio::ip::tcp::resolver::query query(m_host, m_port);
87 m_impl->connect(query);
93 BOOST_ASSERT(m_impl !=
nullptr);
100 BOOST_ASSERT(m_impl !=
nullptr);
101 m_impl->send(header, payload);
107 BOOST_ASSERT(m_impl !=
nullptr);
115 if (m_impl !=
nullptr) {
123 BOOST_ASSERT(m_impl !=
nullptr);
Copyright (c) 2011-2015 Regents of the University of California.
virtual void resume() override
resume the transport
represents the underlying protocol and address used by a Face
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback) override
asynchronously open the connection
Class representing a wire element of NDN-TLV packet format.
const std::string & getScheme() const
get scheme (protocol)
virtual void send(const Block &wire) override
send a TLV block through the transport
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE std::string getSocketHostAndPortFromUri(const std::string &uri)
static shared_ptr< TcpTransport > create(const std::string &uri)
Create transport with parameters defined in URI.
const std::string & getPort() const
get port
virtual void close() override
Close the connection.
const std::string & getHost() const
get host (domain)
TcpTransport(const std::string &host, const std::string &port="6363")
virtual void pause() override
pause the transport
function< void(const Block &wire)> ReceiveCallback
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback)
asynchronously open the connection