22 #ifndef NDN_ASYNC_TCP_TRANSPORT_HPP
23 #define NDN_ASYNC_TCP_TRANSPORT_HPP
26 #include "../common.hpp"
27 #include "../c/encoding/element-reader-types.h"
28 #include "transport.hpp"
30 namespace boost {
namespace asio {
class io_service; }}
54 : host_(host), port_(port)
132 send(
const uint8_t *data,
size_t dataLength);
152 boost::asio::io_service& ioService_;
156 class SocketTransport;
157 ptr_lib::shared_ptr<SocketTransport> socketTransport_;
158 ConnectionInfo connectionInfo_;
virtual bool isAsync()
Override to return true since connect needs to use the onConnected callback.
virtual void close()
Close the connection to the host.
Definition: transport.hpp:32
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
Copyright (C) 2015-2016 Regents of the University of California.
Definition: threadsafe-face.hpp:27
An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElem...
Definition: element-listener.hpp:33
An AsyncTcpTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the host and port info...
Definition: async-tcp-transport.hpp:46
virtual void processEvents()
Do nothing since the asio io_service reads the socket.
virtual void send(const uint8_t *data, size_t dataLength)
Send data to the host.
unsigned short getPort() const
Get the port given to the constructor.
Definition: async-tcp-transport.hpp:70
const std::string & getHost() const
Get the host given to the constructor.
Definition: async-tcp-transport.hpp:63
AsyncTcpTransport extends Transport for async communication over TCP using Boost's asio io_service...
Definition: async-tcp-transport.hpp:40
virtual void connect(const Transport::ConnectionInfo &connectionInfo, ElementListener &elementListener, const OnConnected &onConnected)
Connect according to the info in connectionInfo, and use elementListener.
AsyncTcpTransport(boost::asio::io_service &ioService)
Create an AsyncTcpTransport in the unconnected state.
A Transport::ConnectionInfo is a base class for connection information used by subclasses of Transpor...
Definition: transport.hpp:38
virtual bool isLocal(const Transport::ConnectionInfo &connectionInfo)
Determine whether this transport connecting according to connectionInfo is to a node on the current m...
ConnectionInfo(const char *host, unsigned short port=6363)
Create a ConnectionInfo with the given host and port.
Definition: async-tcp-transport.hpp:53