blob: 4be901f28fb5192800796bb018e1ed56b1d944da [file] [log] [blame]
/**
* @author: Jeff Thompson
* See COPYING for copyright and distribution information.
*/
#ifndef NDN_TRANSPORT_HPP
#define NDN_TRANSPORT_HPP
#include <vector>
namespace ndn {
class Face;
class Transport {
public:
/**
* Connect to the host specified in face.
* @param face Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
*/
virtual void connect(Face &face);
/**
* Set data to the host
* @param data A pointer to the buffer of data to send.
* @param dataLength The number of bytes in data.
*/
virtual void send(const unsigned char *data, unsigned int dataLength);
void send(const std::vector<unsigned char> &data)
{
send(&data[0], data.size());
}
/**
* Process any data to receive. For each element received, call face.onReceivedElement.
* This is non-blocking and will silently time out after a brief period if there is no data to receive.
* You should repeatedly call this from an event loop.
* @throw This may throw an exception for reading data or in the callback for processing the data. If you
* call this from an main event loop, you may want to catch and log/disregard all exceptions.
*/
virtual void processEvents() = 0;
/**
* Close the connection. This base class implementation does nothing, but your derived class can override.
*/
virtual void close();
};
}
#endif