33 time::milliseconds TcpTransport::s_initialReconnectWait = time::seconds(1);
34 time::milliseconds TcpTransport::s_maxReconnectWait = time::minutes(5);
35 float TcpTransport::s_reconnectWaitMultiplier = 2.0f;
39 , m_remoteEndpoint(m_socket.remote_endpoint())
40 , m_nextReconnectWait(s_initialReconnectWait)
45 if (
m_socket.local_endpoint().address().is_loopback() &&
46 m_socket.remote_endpoint().address().is_loopback())
79 boost::system::error_code error;
91 TcpTransport::reconnect()
111 [
this] { handleReconnectTimeout(); });
112 m_socket.async_connect(m_remoteEndpoint,
113 [
this] (
const boost::system::error_code& error) { handleReconnect(error); });
117 TcpTransport::handleReconnect(
const boost::system::error_code& error)
122 error == boost::asio::error::operation_aborted) {
132 m_reconnectEvent.
cancel();
133 m_nextReconnectWait = s_initialReconnectWait;
142 TcpTransport::handleReconnectTimeout()
145 boost::system::error_code error;
149 m_nextReconnectWait =
150 std::min(time::duration_cast<time::milliseconds>(m_nextReconnectWait * s_reconnectWaitMultiplier),
160 m_reconnectEvent.
cancel();
virtual void doClose() override
performs Transport specific operations to close the transport
void cancel()
cancels the event manually
void doClose() final
performs Transport specific operations to close the transport
TcpTransport(protocol::socket &&socket, ndn::nfd::FacePersistency persistency)
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
#define NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(cls, specialization, name)
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void setRemoteUri(const FaceUri &uri)
virtual void handleError(const boost::system::error_code &error)
represents the underlying protocol and address used by a Face
detail::SimulatorIo & getGlobalIoService()
boost::asio::ip::tcp protocol
void setLinkType(ndn::nfd::LinkType linkType)
Implements Transport for stream-based protocols.
protocol::socket m_socket
the transport is being closed due to a failure
void setScope(ndn::nfd::FaceScope scope)
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
TransportState getState() const
Copyright (c) 2011-2015 Regents of the University of California.
the transport is closed, and can be safely deallocated
void post(const std::function< void()> &callback)
void setLocalUri(const FaceUri &uri)
void handleError(const boost::system::error_code &error) final
the transport is requested to be closed
void beforeChangePersistency(ndn::nfd::FacePersistency newPersistency) final
invoked before persistency is changed
void resetReceiveBuffer()
ndn::nfd::FacePersistency getPersistency() const
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
void setState(TransportState newState)
set transport state
the transport is down temporarily, and is being recovered