NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
tcp-channel.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#ifndef NFD_DAEMON_FACE_TCP_CHANNEL_HPP
27
#define NFD_DAEMON_FACE_TCP_CHANNEL_HPP
28
29
#include "
channel.hpp
"
30
#include "
core/scheduler.hpp
"
31
32
namespace
nfd
{
33
34
namespace
tcp {
35
typedef
boost::asio::ip::tcp::endpoint
Endpoint
;
36
}
// namespace tcp
37
45
class
TcpChannel
:
public
Channel
46
{
47
public
:
54
explicit
55
TcpChannel
(
const
tcp::Endpoint
& localEndpoint);
56
66
void
67
listen(
const
FaceCreatedCallback
& onFaceCreated,
68
const
FaceCreationFailedCallback
& onAcceptFailed,
69
int
backlog = boost::asio::ip::tcp::acceptor::max_connections);
70
74
void
75
connect(
const
tcp::Endpoint
& remoteEndpoint,
76
const
FaceCreatedCallback
& onFaceCreated,
77
const
FaceCreationFailedCallback
& onConnectFailed,
78
const
time::seconds& timeout = time::seconds(4));
79
83
size_t
84
size()
const
;
85
86
bool
87
isListening()
const
;
88
89
private
:
90
void
91
createFace(boost::asio::ip::tcp::socket&& socket,
92
const
FaceCreatedCallback
& onFaceCreated,
93
bool
isOnDemand);
94
95
void
96
accept(
const
FaceCreatedCallback
& onFaceCreated,
97
const
FaceCreationFailedCallback
& onAcceptFailed);
98
99
void
100
handleAccept(
const
boost::system::error_code& error,
101
const
FaceCreatedCallback
& onFaceCreated,
102
const
FaceCreationFailedCallback
& onAcceptFailed);
103
104
void
105
handleConnect(
const
boost::system::error_code& error,
106
const
shared_ptr<boost::asio::ip::tcp::socket>& socket,
107
const
scheduler::EventId
& connectTimeoutEvent,
108
const
FaceCreatedCallback
& onFaceCreated,
109
const
FaceCreationFailedCallback
& onConnectFailed);
110
111
void
112
handleConnectTimeout(
const
shared_ptr<boost::asio::ip::tcp::socket>& socket,
113
const
FaceCreationFailedCallback
& onConnectFailed);
114
115
private
:
116
std::map<tcp::Endpoint, shared_ptr<Face>> m_channelFaces;
117
118
tcp::Endpoint
m_localEndpoint;
119
boost::asio::ip::tcp::acceptor m_acceptor;
120
boost::asio::ip::tcp::socket m_acceptSocket;
121
};
122
123
inline
bool
124
TcpChannel::isListening
()
const
125
{
126
return
m_acceptor.is_open();
127
}
128
129
}
// namespace nfd
130
131
#endif // NFD_DAEMON_FACE_TCP_CHANNEL_HPP
nfd::FaceCreationFailedCallback
function< void(const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
Definition:
channel.hpp:44
nfd::Channel
Definition:
channel.hpp:47
channel.hpp
nfd::TcpChannel
Class implementing TCP-based channel to create faces.
Definition:
tcp-channel.hpp:45
ndn::util::scheduler::EventId
std::shared_ptr< ns3::EventId > EventId
Definition:
scheduler.hpp:39
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::tcp::Endpoint
boost::asio::ip::tcp::endpoint Endpoint
Definition:
tcp-channel.hpp:35
nfd::TcpChannel
TcpChannel
Definition:
tcp-channel.cpp:33
scheduler.hpp
nfd::FaceCreatedCallback
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when the face is created (as a response to incoming connec...
Definition:
channel.hpp:38
nfd::TcpChannel::isListening
bool isListening() const
Definition:
tcp-channel.hpp:124
ndnSIM
NFD
daemon
face
tcp-channel.hpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12