• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ tcp::endpoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中boost::asio::ip::tcp::endpoint的典型用法代码示例。如果您正苦于以下问题:C++ endpoint类的具体用法?C++ endpoint怎么用?C++ endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了endpoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: convertEndpointToAddress

Sirikata::Network::Address convertEndpointToAddress(const boost::asio::ip::tcp::endpoint&ep) {
    std::ostringstream address;
    address<<ep.address();
    std::ostringstream port;
    port<<ep.port();
    return Address (address.str(),port.str());
}
开发者ID:namwkim,项目名称:sirikata,代码行数:7,代码来源:ASIOSocketWrapper.cpp


示例2:

FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint, const std::string& scheme)
  : m_scheme(scheme)
{
  m_isV6 = endpoint.address().is_v6();
  m_host = endpoint.address().to_string();
  m_port = boost::lexical_cast<std::string>(endpoint.port());
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:7,代码来源:face-uri.cpp


示例3: handle

void ServicePort::handle(Acceptor_ptr acceptor, boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error)
{
	if(!error)
	{
		if(m_services.empty())
		{
#ifdef __DEBUG_NET__
			std::clog << "[Error - ServerPort::handle] No services running!" << std::endl;
#endif
			return;
		}

		boost::system::error_code error;
		const boost::asio::ip::tcp::endpoint ip = socket->remote_endpoint(error);

		uint32_t remoteIp = 0;
		if(!error)
			remoteIp = htonl(ip.address().to_v4().to_ulong());

		Connection_ptr connection;
		if(remoteIp && ConnectionManager::getInstance()->acceptConnection(remoteIp) &&
			(connection = ConnectionManager::getInstance()->createConnection(
			socket, m_io_service, shared_from_this())))
		{
			if(m_services.front()->isSingleSocket())
				connection->handle(m_services.front()->makeProtocol(connection));
			else
				connection->accept();
		}
		else if(socket->is_open())
		{
			boost::system::error_code error;
			socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, error);

			socket->close(error);
			delete socket;
		}

#ifdef __DEBUG_NET_DETAIL__
		std::clog << "handle - OK" << std::endl;
#endif
		accept(acceptor);
	}
	else if(error != boost::asio::error::operation_aborted)
	{
		PRINT_ASIO_ERROR("Handling");
		close();
		if(!m_pendingStart)
		{
			m_pendingStart = true;
			Scheduler::getInstance().addEvent(createSchedulerTask(5000, boost::bind(
				&ServicePort::service, boost::weak_ptr<ServicePort>(shared_from_this()),
				m_acceptors[acceptor], m_serverPort)));
		}
	}
#ifdef __DEBUG_NET__
	else
		std::clog << "[Error - ServerPort::handle] Operation aborted." << std::endl;
#endif
}
开发者ID:081421,项目名称:otxserver,代码行数:60,代码来源:server.cpp


示例4: on_proxy

void node::on_proxy(
    const std::uint16_t & tid, const boost::asio::ip::tcp::endpoint & ep,
    const std::string & value
    )
{
    stack_impl_.on_proxy(
        tid, ep.address().to_string().c_str(), ep.port(), value
    );
}
开发者ID:zonedoutspace,项目名称:vanillacoin,代码行数:9,代码来源:node.cpp


示例5: getIp

int Connection::getIp()
{
    boost::system::error_code error;
    const boost::asio::ip::tcp::endpoint ip = m_socket.remote_endpoint(error);
    if(!error)
        return boost::asio::detail::socket_ops::host_to_network_long(ip.address().to_v4().to_ulong());

    g_logger.error("Getting remote ip");
    return 0;
}
开发者ID:Cadyan,项目名称:otclient,代码行数:10,代码来源:connection.cpp


示例6: getIP

uint32_t Connection::getIP() const
{
	//ip is expressed in network byte order
	boost::system::error_code error;
	const boost::asio::ip::tcp::endpoint ip = m_socket->remote_endpoint(error);
	if(!error)
		return htonl(ip.address().to_v4().to_ulong());

	return 0;
}
开发者ID:novasdream,项目名称:tyano-core,代码行数:10,代码来源:connection.cpp


示例7: connect

void TcpConnectionImpl::connect(boost::asio::ip::tcp::endpoint& endpoint)
{
	if(m_isConnected) return;
	if(m_isClosing) return;

	m_endPoint = endpoint;

	std::cout << "Trying to connect to port " << endpoint.port() << " @ " << endpoint.address().to_string() << std::endl;
	// try to connect, then call handle_connect
    m_socket.async_connect(endpoint, boost::bind(&TcpConnectionImpl::handle_connect, this, boost::asio::placeholders::error));
}
开发者ID:xubingyue,项目名称:TcpConnection,代码行数:11,代码来源:TcpConnectionImpl.cpp


示例8: onAccept

void ServicePort::onAccept(boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error)
{
	if(!error)
	{
		if(m_services.empty())
		{
#ifdef __DEBUG_NET__
			std::cout << "Error: [ServerPort::accept] No services running!" << std::endl;
#endif
			return;
		}

		boost::system::error_code error;
		const boost::asio::ip::tcp::endpoint endpoint = socket->remote_endpoint(error);
		uint32_t remote_ip = 0;
		if(!error)
			remote_ip = htonl(endpoint.address().to_v4().to_ulong());

		if(remote_ip != 0/* && g_bans.acceptConnection(remote_ip)*/)
		{
			Connection_ptr connection = ConnectionManager::getInstance()->createConnection(socket, m_io_service, shared_from_this());
			if(m_services.front()->is_single_socket())
				connection->acceptConnection(m_services.front()->make_protocol(connection));
			else
				connection->acceptConnection();
		}
		else if(socket->is_open())
		{
			boost::system::error_code error;
			socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, error);
			socket->close(error);
			delete socket;
		}
		accept();
	}
	else if(error != boost::asio::error::operation_aborted)
	{
		if(!m_pendingStart)
		{
			close();
			m_pendingStart = true;
			g_scheduler.addEvent(createSchedulerTask(15000,
				boost::bind(&ServicePort::openAcceptor, boost::weak_ptr<ServicePort>(shared_from_this()), m_serverPort)));
		}
	}
	else
	{
		#ifdef __DEBUG_NET__
		std::cout << "Error: [ServicePort::onAccept] Operation aborted." << std::endl;
		#endif
	}
}
开发者ID:Codex-NG,项目名称:TFS-1.0,代码行数:52,代码来源:server.cpp


示例9: getIP

uint32_t Connection::getIP() const
{
	//Ip is expressed in network byte order
	boost::system::error_code error;
	const boost::asio::ip::tcp::endpoint endpoint = m_socket.remote_endpoint(error);
	if(!error)
		return htonl(endpoint.address().to_v4().to_ulong());
	else
	{
		PRINT_ASIO_ERROR("Getting remote ip");
		return 0;
	}
}
开发者ID:tryller,项目名称:otserv,代码行数:13,代码来源:connection.cpp


示例10: lockClass

uint32_t Connection::getIP()
{
	std::lock_guard<std::recursive_mutex> lockClass(connectionLock);

	// IP-address is expressed in network byte order
	boost::system::error_code error;
	const boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(error);
	if (error) {
		return 0;
	}

	return htonl(endpoint.address().to_v4().to_ulong());
}
开发者ID:AdamSC1-ddg,项目名称:forgottenserver,代码行数:13,代码来源:connection.cpp


示例11: VideoDataHandler

    VideoDataHandler(InputStream * is, OutputStream * os, boost::asio::ip::tcp::endpoint e):
    _db(org::esb::hive::DatabaseService::getDatabase())
    {
      _ep=e;
      _os=os;
      _is=is;
      _oos = new io::ObjectOutputStream(os);
      _ois = new io::ObjectInputStream(is);
      _own_id = e.address().to_string();
      _own_id += ":";
      _own_id += StringUtil::toString(e.port());
      shutdown = false;

      LOGDEBUG("endpoint:" << e);
    }
开发者ID:psychobob666,项目名称:MediaEncodingCluster,代码行数:15,代码来源:VideoDataHandler.cpp


示例12: handle

void ServicePort::handle(boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error)
{
	if(!error)
	{
		if(m_services.empty())
		{
			return;
		}

		boost::system::error_code error;
		const boost::asio::ip::tcp::endpoint ip = socket->remote_endpoint(error);

		uint32_t remoteIp = 0;
		if(!error)
			remoteIp = htonl(ip.address().to_v4().to_ulong());

		Connection_ptr connection;
		if(remoteIp && ConnectionManager::getInstance()->acceptConnection(remoteIp) &&
			(connection = ConnectionManager::getInstance()->createConnection(
			socket, m_io_service, shared_from_this())))
		{
			if(m_services.front()->isSingleSocket())
				connection->handle(m_services.front()->makeProtocol(connection));
			else
				connection->accept();
		}
		else if(socket->is_open())
		{
			boost::system::error_code error;
			socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, error);

			socket->close(error);
			delete socket;
		}

		accept();
	}
	else if(error != boost::asio::error::operation_aborted)
	{
		close();
		if(!m_pendingStart)
		{
			m_pendingStart = true;
			server.scheduler().addTask(SchedulerTask::create(Milliseconds(5000), std::bind(
				&ServicePort::onOpen, std::weak_ptr<ServicePort>(shared_from_this()), m_serverPort)));
		}
	}
}
开发者ID:novasdream,项目名称:tyano-core,代码行数:48,代码来源:service.cpp


示例13: handle_read

void handle_read(const boost::system::error_code& ec, std::size_t sz, const boost::asio::ip::tcp::endpoint& endpoint,
        const string& request, int rpe, boost::shared_ptr<Socket> socket, boost::shared_ptr<boost::asio::streambuf> buf)
{
    ycout << endpoint.address() << "<< \r\n"
          << boost::make_iterator_range(boost::asio::buffers_begin(buf->data()),  boost::asio::buffers_begin(buf->data()) + sz)
          << "--";
    make_request<Socket>(socket->get_io_service(), endpoint, request, rpe);
}
开发者ID:alexeimoisseev,项目名称:NwSMTP,代码行数:8,代码来源:spool.cpp


示例14:

void
Socket::connect(const ao::ip::tcp::endpoint & e)
{
    socket_.open(e.protocol());
    socket_.connect(e);

    std::cout << "Connected to '" << e << "'" << std::endl;
}
开发者ID:enyx-opensource,项目名称:net-tools,代码行数:8,代码来源:Socket.cpp


示例15: acceptor

Server::Server(ip::tcp::endpoint endpoint, Server::ConnectionCtor ctor)
  : acceptor(io_service), image_cache(new ImageCache(0x100)), task_pool(new TaskPool()), ctor(ctor), stop(false) {
  new_connection.reset(ctor(io_service, image_cache, task_pool));

  acceptor.open(endpoint.protocol());
  acceptor.set_option(ip::tcp::acceptor::reuse_address(true));
  acceptor.bind(endpoint);
  acceptor.listen();
  acceptor.async_accept(new_connection->Socket(),
    boost::bind(&Server::handle_accept, shared_from_this(), boost::asio::placeholders::error));
}
开发者ID:hatc,项目名称:image-proxy,代码行数:11,代码来源:server.cpp


示例16: EndpointToLua

//////////////////////////////////////////////////////////////////////////
/// Pushes to Lua the data of the endpoint
void Resolver::EndpointToLua(lua_State* L, const boost::asio::ip::tcp::endpoint& endpoint) {
	const boost::asio::ip::address& address = endpoint.address();
	std::string s = endpoint.address().to_string();
	lua_newtable(L);
	lua_pushstring(L, address.to_string().c_str());
	lua_setfield(L, -2, "address");

	lua_pushnumber(L, endpoint.port());
	lua_setfield(L, -2, "port");

	if(endpoint.address().is_v6()) {
		lua_pushnumber(L, 6);
	}
	else if(endpoint.address().is_v4()) {
		lua_pushnumber(L, 4);
	}
	else {
		lua_pushliteral(L, "unknown");
	}
	lua_setfield(L, -2, "family");
}
开发者ID:mkottman,项目名称:LuaNode,代码行数:23,代码来源:luanode_dns.cpp


示例17: onAccept

void ServicePort::onAccept(boost::asio::ip::tcp::socket* socket, const boost::system::error_code& error)
{
	if (!error) {
		if (m_services.empty()) {
			return;
		}

		boost::system::error_code socketError;
		const boost::asio::ip::tcp::endpoint endpoint = socket->remote_endpoint(socketError);

		uint32_t remote_ip = 0;
		if (!socketError) {
			remote_ip = htonl(endpoint.address().to_v4().to_ulong());
		}

		if (remote_ip != 0 && g_bans.acceptConnection(remote_ip)) {
			Connection_ptr connection = ConnectionManager::getInstance()->createConnection(socket, m_io_service, shared_from_this());
			Service_ptr service = m_services.front();

			if (service->is_single_socket()) {
				connection->acceptConnection(service->make_protocol(connection));
			} else {
				connection->acceptConnection();
			}
		} else if (socket->is_open()) {
			socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, socketError);
			socket->close(socketError);
			delete socket;
		}

		accept();
	} else if (error != boost::asio::error::operation_aborted) {
		if (!m_pendingStart) {
			close();
			m_pendingStart = true;
			g_scheduler.addEvent(createSchedulerTask(15000,
			                     boost::bind(&ServicePort::openAcceptor, boost::weak_ptr<ServicePort>(shared_from_this()), m_serverPort)));
		}
	}
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:40,代码来源:server.cpp


示例18:

	PrivateData( int portNumber ) :
		m_success(false),
		m_endpoint(tcp::v4(), portNumber),
		m_service(),
		m_acceptor( m_service ),
		m_thread()
	{
		m_acceptor.open(  m_endpoint.protocol() );
		m_acceptor.set_option( boost::asio::ip::tcp::acceptor::reuse_address(true));
		m_acceptor.bind( m_endpoint );
		m_acceptor.listen();
		m_success = true;
	}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:13,代码来源:DisplayDriverServer.cpp


示例19: server

	server(boost::asio::io_service & io_service,
				const boost::asio::ip::tcp::endpoint & endpoint)
		: io_service_(io_service)
		, acceptor_(io_service_, endpoint)
	{
		std::cout << esc(MAKE_GREEN)
			<< LOG_HEADER
			<< "Echo server is listening on port: "
			<< endpoint.port()
			<< esc(RESET_COLOR)
			<< std::endl;
		start_accept();
	}
开发者ID:mpapierski,项目名称:simpledaemon,代码行数:13,代码来源:main.cpp


示例20: isValidTarget

bool TargetedCertificateManager::isValidTarget(boost::asio::ip::tcp::endpoint &endpoint,
					       bool wildcardOK) {

  boost::asio::ip::address address      = endpoint.address();
  std::list<Certificate*>::iterator i   = certificates.begin();
  std::list<Certificate*>::iterator end = certificates.end();

  for ( ; i != end; i++) {
    if ((*i)->isValidTarget(address, wildcardOK)) return true;
  }

  return false;
}
开发者ID:Andlab,项目名称:sslsniff,代码行数:13,代码来源:TargetedCertificateManager.cpp



注:本文中的boost::asio::ip::tcp::endpoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ tcp::socket类代码示例发布时间:2022-05-31
下一篇:
C++ tcp::acceptor类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap