tcp-transport.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_TRANSPORT_HPP
27 #define NFD_DAEMON_FACE_TCP_TRANSPORT_HPP
28 
29 #include "stream-transport.hpp"
30 #include "core/scheduler.hpp"
31 
32 namespace nfd {
33 namespace face {
34 
42 class TcpTransport FINAL_UNLESS_WITH_TESTS : public StreamTransport<boost::asio::ip::tcp>
43 {
44 public:
45  TcpTransport(protocol::socket&& socket, ndn::nfd::FacePersistency persistency);
46 
47 protected:
48  bool
49  canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const final;
50 
51  void
52  afterChangePersistency(ndn::nfd::FacePersistency oldPersistency) final;
53 
54  void
55  doClose() final;
56 
57  void
58  handleError(const boost::system::error_code& error) final;
59 
62  reconnect();
63 
65  handleReconnect(const boost::system::error_code& error);
66 
68  handleReconnectTimeout();
69 
73  static time::milliseconds s_initialReconnectWait;
74 
77  static time::milliseconds s_maxReconnectWait;
78 
81  static float s_reconnectWaitMultiplier;
82 
83 private:
84  typename protocol::endpoint m_remoteEndpoint;
85 
88  scheduler::ScopedEventId m_reconnectEvent;
89 
92  time::milliseconds m_nextReconnectWait;
93 };
94 
95 } // namespace face
96 } // namespace nfd
97 
98 #endif // NFD_DAEMON_FACE_TCP_TRANSPORT_HPP
TcpTransport(protocol::socket &&socket, ndn::nfd::FacePersistency persistency)
cancels an event automatically upon destruction
Definition: scheduler.hpp:56
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
Implements Transport for stream-based protocols.
bool canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const final
invoked by canChangePersistencyTo to perform the check
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
void afterChangePersistency(ndn::nfd::FacePersistency oldPersistency) final
invoked after the persistency has been changed
void handleError(const boost::system::error_code &error) final
A Transport that communicates on a connected TCP socket.
#define VIRTUAL_WITH_TESTS
Definition: common.hpp:38
void doClose() final
performs Transport specific operations to close the transport
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
#define FINAL_UNLESS_WITH_TESTS
Definition: common.hpp:42