40 shared_ptr<TcpTransport>
44 return make_shared<TcpTransport>(hostAndPort.first, hostAndPort.second);
47 std::pair<std::string, std::string>
52 std::string host =
"localhost";
53 std::string port =
"6363";
56 const util::FaceUri uri(parsed.get<std::string>(
"transport",
"tcp://" + host));
58 const std::string scheme = uri.
getScheme();
59 if (scheme !=
"tcp" && scheme !=
"tcp4" && scheme !=
"tcp6") {
60 BOOST_THROW_EXCEPTION(
Transport::Error(
"Cannot create TcpTransport from \"" +
83 if (!static_cast<bool>(m_impl)) {
86 m_impl = make_shared<Impl>(ref(*
this), ref(ioService));
89 boost::asio::ip::tcp::resolver::query query(m_host, m_port);
90 m_impl->connect(query);
96 BOOST_ASSERT(static_cast<bool>(m_impl));
103 BOOST_ASSERT(static_cast<bool>(m_impl));
104 m_impl->send(header, payload);
110 BOOST_ASSERT(static_cast<bool>(m_impl));
118 if (static_cast<bool>(m_impl)) {
126 BOOST_ASSERT(static_cast<bool>(m_impl));
virtual void connect(boost::asio::io_service &io_service, const ReceiveCallback &receiveCallback)
Connect transport.
Copyright (c) 2011-2015 Regents of the University of California.
static shared_ptr< TcpTransport > create(const ConfigFile &config)
represents the underlying protocol and address used by a Face
Class representing a wire element of NDN-TLV packet format.
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback)
Connect transport.
const std::string & getScheme() const
get scheme (protocol)
virtual void send(const Block &wire)
Send block of data from.
function< void(const Block &wire)> ReceiveCallback
const std::string & getPort() const
get port
boost::property_tree::ptree Parsed
virtual void close()
Close the connection.
const std::string & getHost() const
get host (domain)
TcpTransport(const std::string &host, const std::string &port="6363")
const Parsed & getParsedConfiguration() const
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE std::string getDefaultSocketHostAndPort(const ConfigFile &config)