if (! file.fail()) {
                std::string cookie;
                file >> cookie;
                size_t n = cookie.find('\n');
                if (n != std::string::npos) cookie.erase(n);
                if (cookie.size() > EI_MAX_COOKIE_SIZE)
                    throw err_bad_argument("Cookie size too long", cookie.size());
                return atom(cookie);
            }
        }
        return atom();
    }

} // namespace

atom        basic_otp_node_local::s_default_cookie = get_default_cookie();
std::string basic_otp_node_local::s_localhost      = boost::asio::ip::host_name();

basic_otp_node_local::basic_otp_node_local(
    const std::string& a_nodename, const std::string& a_cookie)
    throw (std::runtime_error, err_bad_argument)
{
    set_nodename(a_nodename, a_cookie);
}

void basic_otp_node_local::set_nodename(
    const std::string& a_nodename, const std::string& a_cookie)
    throw (std::runtime_error, err_bad_argument)
{
    if (m_cookie.size() > EI_MAX_COOKIE_SIZE)
        throw err_bad_argument("Cookie size too long", m_cookie.size());
Example #2
0
                << ".erlang.cookie";
            std::ifstream file(s.str().c_str());
            if (! file.fail()) {
                std::string cookie;
                file >> cookie;
                size_t n = cookie.find('\n');
                if (n != std::string::npos) cookie.erase(n);
                return cookie;
            }
        }
        return "no_cookie";
    }

} // namespace

std::string basic_otp_node_local::s_default_cookie = get_default_cookie();
std::string basic_otp_node_local::s_localhost      = boost::asio::ip::host_name();

basic_otp_node_local::basic_otp_node_local(
    const std::string& a_nodename, const std::string& a_cookie)
    throw (std::runtime_error, err_bad_argument)
{
    set_nodename(a_nodename, a_cookie);
}

void basic_otp_node_local::set_nodename(
    const std::string& a_nodename, const std::string& a_cookie)
    throw (std::runtime_error, err_bad_argument)
{
    m_cookie = a_cookie.empty() ? s_default_cookie : a_cookie;