コード例 #1
0
ファイル: https_client.cpp プロジェクト: 10jschen/acl
bool https_client::connect_server(acl::http_client& client)
{
	logger_debug(DEBUG, 1, "begin connect server");

	if (client.open(server_addr_.c_str(), 60, 60, true) == false)
	{
		logger_error("failed to connect server %s", server_addr_.c_str());
		return false;
	}
	else
		logger_debug(DEBUG, 1, "connect server ok");

	if (ssl_conf_)
	{
		logger_debug(DEBUG, 1, "begin open ssl");

		acl::polarssl_io* ssl = new acl::polarssl_io(*ssl_conf_, false);
		if (client.get_stream().setup_hook(ssl) == ssl)
		{
			logger_error("open ssl client error");
			ssl->destroy();
			return false;
		}
		else
			logger_debug(DEBUG, 1, "open ssl ok");
	}

	return true;
}
コード例 #2
0
ファイル: https_client.cpp プロジェクト: neland/acl
bool https_client::connect_server(const acl::string& server_addr,
	acl::http_client& client)
{
	// 先查本地映射表中有没有映射项
	master_service& ms = acl::singleton2<master_service>::get_instance();
	const char* addr = ms.get_addr(server_addr.c_str());
	if (addr == NULL)
		addr = server_addr.c_str();

	if (client.open(addr, 60, 60, true) == false)
	{
		out_.format("connect server %s error", addr);
		return false;
	}
	else
		logger_debug(DEBUG, 1, "connect server ok");

	if (ssl_conf_)
	{
		logger_debug(DEBUG, 1, "begin open ssl");

		acl::polarssl_io* ssl = new acl::polarssl_io(*ssl_conf_, false);
		if (client.get_stream().setup_hook(ssl) == ssl)
		{
			out_.puts("open ssl client error");
			ssl->destroy();
			return false;
		}
		else
			logger_debug(DEBUG, 1, "open ssl ok");
	}

	return true;
}