Ejemplo n.º 1
0
ndn_Error
TcpTransportLite::isLocal(const char *host, bool& result)
{
    int intResult;
    ndn_Error status = ndn_TcpTransport_isLocal(host, &intResult);
    result = (intResult != 0);

    return status;
}
Ejemplo n.º 2
0
bool
TcpTransport::isLocal(const Transport::ConnectionInfo& connectionInfo)
{
  const TcpTransport::ConnectionInfo& tcpConnectionInfo =
    dynamic_cast<const TcpTransport::ConnectionInfo&>(connectionInfo);

  if (connectionInfo_.getHost() == "" ||
      connectionInfo_.getHost() != tcpConnectionInfo.getHost()) {
    ndn_Error error;
    int intIsLocal;
    if ((error = ndn_TcpTransport_isLocal
         ((char *)tcpConnectionInfo.getHost().c_str(), &intIsLocal)))
      throw runtime_error(ndn_getErrorString(error));

    // Cache the result in isLocal_ and save connectionInfo_ for next time.
    connectionInfo_ = tcpConnectionInfo;
    isLocal_ = (intIsLocal != 0);
  }

  return isLocal_;
}