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

C++ endpoint函数代码示例

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

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



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

示例1: server

static void server()
{
	ENetEndpoint endpoint(SOCK_STREAM);

	if(endpoint.InitCheck() != E_OK) ETK_ERROR("Failed to create endpoint: %s.", endpoint.ErrorStr());
	if(endpoint.Bind(DEFAULT_PORT) != E_OK) ETK_ERROR("Bind(%d) failed: %s.", DEFAULT_PORT, endpoint.ErrorStr());
	if(endpoint.Listen() != E_OK) ETK_ERROR("Listen() failed: %s.", endpoint.ErrorStr());

	while(true)
	{
		ETK_OUTPUT("Waiting for client ...\n");

		ENetEndpoint *connection = endpoint.Accept(500);
		if(connection == NULL)
		{
			ETK_WARNING("Accept() == NULL: %s.", endpoint.ErrorStr());
			continue;
		}

		struct in_addr addr;
		euint16 port;
		connection->RemoteAddr().GetAddr(addr, &port);

		euint32 ip = E_BENDIAN_TO_HOST_INT32(addr.s_addr);
		ETK_OUTPUT("connection from %d.%d.%d.%d, port: %d\n",
			   ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff, port);

		EString buf;
		time_t curTime = time(NULL);
		buf << ctime(&curTime) << "\r\n";
		connection->Send(buf.String(), buf.Length());

		delete connection;
	}
}
开发者ID:D-os,项目名称:EasyToolkitAndExtension,代码行数:35,代码来源:net-test.cpp


示例2: endpoint

void BoostConnection::connect(const HostAddressPort& addressPort) {
	boost::asio::ip::tcp::endpoint endpoint(	
			boost::asio::ip::address::from_string(addressPort.getAddress().toString()), addressPort.getPort());
	socket_.async_connect(
			endpoint,
			boost::bind(&BoostConnection::handleConnectFinished, shared_from_this(), boost::asio::placeholders::error));
}
开发者ID:bessey,项目名称:picnic-doc-server,代码行数:7,代码来源:BoostConnection.cpp


示例3: endpoint

void Connection::Bind(const std::string & ip, uint16_t port)
{
	boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(ip), port);
	m_socket.open(endpoint.protocol());
	m_socket.set_option(boost::asio::ip::tcp::acceptor::reuse_address(false));
	m_socket.bind(endpoint);
}
开发者ID:miguelangelo78,项目名称:BoostAsio-Net-Wrapper,代码行数:7,代码来源:network_sockapi.cpp


示例4: client

static void client(const char *address)
{
	ENetEndpoint endpoint(SOCK_STREAM);

	if(endpoint.InitCheck() != E_OK) ETK_ERROR("Failed to create endpoint: %s.", endpoint.ErrorStr());
	if(endpoint.Connect(address, DEFAULT_PORT) != E_OK) ETK_ERROR("Connect() failed: %s.", endpoint.ErrorStr());
	endpoint.SetTimeout(E_INFINITE_TIMEOUT);

	char buf[BUF_SIZE];
	size_t pos = 0;

	bzero(buf, BUF_SIZE);

	while(pos < BUF_SIZE - 1)
	{
		ETK_OUTPUT("Receiving ...\n");

		eint32 bytes = endpoint.Receive(buf + pos, BUF_SIZE - pos - 1);
		if(bytes < 0) break;

		pos += bytes;
		if(pos < 3) continue;

		if(buf[pos - 1] == '\n' && buf[pos - 2] == '\r') break;
	}

	ENetDebug::Enable(true);
	ENetDebug::Dump(buf, pos, "Received");

	ETK_OUTPUT("Received: %s", buf);
}
开发者ID:D-os,项目名称:EasyToolkitAndExtension,代码行数:31,代码来源:net-test.cpp


示例5: BOOST_FOREACH

void Request::updatePeers(const std::vector<boost::asio::ip::tcp::endpoint>& peers) {
  /* filter the new nodes */
  BOOST_FOREACH(const boost::asio::ip::tcp::endpoint& peer, peers) {
#ifdef GOLD /* for debugging we need to be able to relay back to the origin */
    if (peer == endpoint()) {
      continue;
    }
#endif
    bool seenBefore = false;
    BOOST_FOREACH(const boost::asio::ip::tcp::endpoint& old, peers_) {
      if (peer == old) {
        seenBefore = true;
        break;
      }
    }
    BOOST_FOREACH(const boost::asio::ip::tcp::endpoint& old, peersDone_) {
      if (peer == old) {
        seenBefore = true;
        break;
      }
    }
    if (!seenBefore) {
      peers_.push_back(peer);
    }
  }
}
开发者ID:sigint9,项目名称:torrentmod,代码行数:26,代码来源:request.cpp


示例6: startpoint

void Wall::ShowStructure(QGraphicsScene *c) {

  Vector offset = Cell::Offset();
  double factor = Cell::Factor();

  Vector startpoint ( ((offset.x+n1->x)*factor),((offset.y+n1->y)*factor)),
    endpoint (((offset.x+n2->x)*factor),((offset.y+n2->y)*factor));

  Vector linevec = endpoint - startpoint;
  Vector midline = startpoint + linevec/2.;
  Vector perpvec = linevec.Normalised().Perp2D();
  Vector textpos1 = midline + 100 * perpvec;
  Vector textpos2 = midline - 100 * perpvec;

  QGraphicsLineItem *line = new QGraphicsLineItem(0,c);

  line->setPen( QPen(QColor(par.arrowcolor),2) );
  line->setLine(startpoint.x, startpoint.y, endpoint.x, endpoint.y );
  line->setZValue(10);
  line->show();

  QGraphicsSimpleTextItem *text1 = new QGraphicsSimpleTextItem( QString("%1").arg(c2->Index()),0,c);
  QGraphicsSimpleTextItem *text2 = new QGraphicsSimpleTextItem( QString("%1").arg(c1->Index()),0,c);

  text1 -> setPos( textpos1.x, textpos1.y );
  text2 -> setPos( textpos2.x, textpos2.y );
  text1->setZValue(20); text2->setZValue(20);

  text1->setFont( QFont( "Helvetica", par.nodenumsize, QFont::Bold) );
  text2->setFont( QFont( "Helvetica", par.nodenumsize, QFont::Bold) );

  text1->setPen ( QColor(par.textcolor) );
  text2->setPen ( text1->pen() );
  text1->show(); text2->show();
}
开发者ID:maleiwhat,项目名称:virtualleaf,代码行数:35,代码来源:wall.cpp


示例7: main

int main(int argc, char *argv[])
{
    int node_id = 1;
    if (argc == 2)
    {
        node_id = atoi(argv[1]);
    }

    network::IOServiceThreadManager threads(2);
    std::unique_ptr<connector::gw::Client> client;
    asio::ip::tcp::endpoint endpoint(asio::ip::address_v4::from_string("127.0.0.1"), 5150);

    try
    {
        client = std::make_unique<connector::gw::Client>(threads, endpoint, 1, gateway::SvrType::kLoginServer, node_id);
    }
    catch (const std::exception&)
    {
        std::cerr << "连接网关服务器失败!" << std::endl;
        getchar();
        exit(1);
    }
    std::cerr << "连接网关服务器成功!" << std::endl;

    client->set_message_callback([](connector::gw::Client *cli, google::protobuf::Message *msg, network::NetMessage &buf)
    {
    });

    threads.run();

    return 0;
}
开发者ID:zhangpanyi,项目名称:eddyserver,代码行数:32,代码来源:test.cpp


示例8: endpoint

int RTSPServer::Start(unsigned short rtsp_port, std::size_t thread_pool_size)
{

	m_rtspListenPort = rtsp_port;
	m_threadPoolSize = thread_pool_size;

	int iret = -1;
	try
	{
		boost::asio::ip::tcp::endpoint endpoint(
			boost::asio::ip::tcp::v4(), m_rtspListenPort);
		m_acceptor_.open(endpoint.protocol());
		m_acceptor_.bind(endpoint);
		m_acceptor_.listen();

		StartAccpet();
		m_bStoped = false;
		iret = 0;
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}

	return iret;
}
开发者ID:lubing521,项目名称:MediaServer,代码行数:26,代码来源:RTSPServer.cpp


示例9: listener_loop

void listener_loop(int port_number)
{
	boost::thread workerThread3(updateMeasurement);
	

	boost::asio::io_service io_service;
	boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port_number);
	boost::asio::ip::tcp::acceptor acceptor(io_service, endpoint);

	
	while(true)
	{
		try
		{

			boost::shared_ptr<boost::asio::ip::tcp::socket> socket = boost::make_shared<boost::asio::ip::tcp::socket>(boost::ref(io_service));
			established_connections.push_back(socket);
			std::cout << "TCP server ready and listening ... " << std::endl;
			acceptor.accept(*established_connections.back());
			std::cout << "Number of established client connections: ";
			std::cout << established_connections.size() << std::endl;
			
			boost::thread workerThread2(worker,established_connections.back());
			
		}
		catch(std::exception& e)
		{
			std::cerr << "Exception: " << e.what() << std::endl;
		}
	}
}
开发者ID:Shalelol,项目名称:tmc,代码行数:31,代码来源:TMCSnesorServer.cpp


示例10: ServiceServer

IPCServer::IPCServer( const std::string & path,
                      const std::size_t worker_pool_size )
	: ServiceServer( worker_pool_size ),
	  new_connection_(),
	  acceptor_( io_service_ )
{
	unlink( path.c_str() );

	try {
		asio::local::stream_protocol::endpoint endpoint( path );

		acceptor_.open( endpoint.protocol() );
		acceptor_.bind( endpoint );
		acceptor_.listen();

	} catch( boost::system::system_error & e ) {
		throw( new IPCServerException( "Unable to create IPC server." ) );
	}

	try {
		start_accept();
	} catch( IPCServerException & ipc_e ) {
		throw;
	}

#ifndef NDEBUG
	logger->log( Logger::DEBUG, "IPC server created and accepting connections." );
#endif
}
开发者ID:JulianKunkel,项目名称:siox,代码行数:29,代码来源:IPCServer.cpp


示例11: endpoint

void RedisAsyncClient::connect(const boost::asio::ip::address &address,
                               unsigned short port,
                               std::function<void(bool, const std::string &)> handler)
{
    boost::asio::ip::tcp::endpoint endpoint(address, port);
    connect(endpoint, std::move(handler));
}
开发者ID:ash-github,项目名称:redisclient,代码行数:7,代码来源:redisasyncclient.cpp


示例12: main

int main(int argc, char *argv[])
{
    boost::asio::io_service io;
    boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::udp::v4(), 12346);
    server s(io, endpoint);
    io.run();
    return 0;
}
开发者ID:breese,项目名称:plex,代码行数:8,代码来源:async_echo_server.cpp


示例13: endpoint

void NoeudThor::startConnectSecureNodeListProvider()
{
	noeudSecureNodeListProvider = new Client<NoeudThor>(this, io_service);
	tcp::endpoint endpoint(boost::asio::ip::address::from_string(ipSecureNodeListProvider), portSecureNodeListProvider);
	cout << "Connection au Secure Node List Provider" << std::endl;
	noeudSecureNodeListProvider->getSocket().connect(endpoint);
	noeudSecureNodeListProvider->startRead();
}
开发者ID:Ektoplasma,项目名称:frontale,代码行数:8,代码来源:noeudthor.cpp


示例14: endpoint

bool TajoSyncClient::connect(const boost::asio::ip::address &address,
        unsigned short port,
        std::string &errmsg)
{
    tcp::endpoint endpoint(address, port);

    return connect(endpoint, errmsg);
}
开发者ID:shyblue,项目名称:tajo-client-cpp,代码行数:8,代码来源:tajo_sync_client.cpp


示例15: StringToEndpoint

udp::endpoint StringToEndpoint(const string &strIpPort)
{
	char szIp[16] = {0};
	unsigned int dwPort;
	sscanf(strIpPort.c_str(), "%[^:]:%d", szIp, &dwPort);
	udp::endpoint endpoint(boost::asio::ip::address::from_string(szIp), dwPort);
	return endpoint;
}
开发者ID:victorzjl,项目名称:BPE,代码行数:8,代码来源:Common.cpp


示例16: get_connection_service

void acceptors_list<Connection>::start_acceptor(size_t index)
{
	acceptor_type &acc = *acceptors[index];

	auto conn = std::make_shared<connection_type>(data.server, get_connection_service(), data.buffer_size);

	acc.async_accept(conn->socket(), conn->endpoint(), boost::bind(
				 &acceptors_list::handle_accept, this, index, conn, _1));
}
开发者ID:iderikon,项目名称:swarm,代码行数:9,代码来源:acceptorlist.cpp


示例17: TLSLOG_L

//---------------------------------------------------------------------------
// The most siginificant method of this class. 
//---------------------------------------------------------------------------
//
TInt CWSStarHttpClient::GetHttpL( const TDesC8& aRequest,
                                  HBufC8*& apResponse,
                                  CSenWSDescription* apSD )
    {
    TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CWSStarHttpClient::GetHttpL");
    TInt retVal(KErrNone);             // for returning error codes
    if( !iInitializer )
        {
        return KErrSenInternal;
        }
    TPtrC8 endpoint(iInitializer->Endpoint());    

    CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC();
    pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpGet);
    _LIT8(KAcceptedHeader, "text/xml,text/plain");    
    pHttpProperties->SetAcceptL(KAcceptedHeader);
    TUint32 desiredIapId(0);
   
    if( apSD )
        {
        TInt getIapRetVal = apSD->IapId( desiredIapId );
        if ( getIapRetVal == KErrNone )
            {
            pHttpProperties->SetIapIdL( desiredIapId );
            }
        }
     //limit http timeout, 
	pHttpProperties->SetMaxTimeToLiveL(WSStarSession::KMaxHttpTimeOut);
	TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KNormalLogLevel, _L8("CWSStarHttpClient::GetHttpL - with IAP ID (%d):"), desiredIapId));    
    HBufC8* pSerializedProperties  = pHttpProperties->AsUtf8L();
    CleanupStack::PopAndDestroy(pHttpProperties);

    CleanupStack::PushL(pSerializedProperties);
    TLSLOG_ALL(KSenCoreServiceManagerLogChannelBase  , KNormalLogLevel,( pSerializedProperties->Des() ));
    retVal = ipTransport->SubmitL(endpoint, aRequest, *pSerializedProperties, apResponse, *this);	
    TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KNormalLogLevel, _L8("CWSStarHttpClient::GetHttpL - SubmitL returned: %d"), retVal));    

    CleanupStack::PopAndDestroy( pSerializedProperties );

#ifdef _SENDEBUG
    if( apResponse )
        {
        TPtrC8 response = apResponse->Des();
        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMaxLogLevel,"* * * * * * * * * * * * *");
        TLSLOG_FORMAT((KSenCoreServiceManagerLogChannelBase  , KMaxLogLevel, _L8("CWSStarHttpClient::GetHttpL - response (%d bytes):"), response.Length()));    
        TLSLOG_ALL(KSenCoreServiceManagerLogChannelBase  , KMaxLogLevel,( response ));
        TLSLOG_L(KSenCoreServiceManagerLogChannelBase  , KMinLogLevel,"CSenCoreServiceManager::CreateL:");
        }
#endif // _SENDEBUG        

    if( retVal != KErrNone )
        {
        delete apResponse; 
        apResponse = NULL;
        }
    return retVal;
    }
开发者ID:gvsurenderreddy,项目名称:symbiandump-mw4,代码行数:61,代码来源:wsstarhttpclient.cpp


示例18: endpoint

		void EthernetRelayDriver::configure(std::string host, int port){

			tcp::endpoint endpoint(boost::asio::ip::address::from_string(host.c_str()), port);
			socket.connect(endpoint);

			if(socket.is_open()){
				ROS_INFO("TCP/IP socket opened.");
			}
		}
开发者ID:sweapon,项目名称:vehicles-ros-pkg,代码行数:9,代码来源:ethernetRelayDriver.hpp


示例19: endpoint

int AMHS_Server::Start(int nPort)
{
	tcp::endpoint endpoint(tcp::v4(), nPort);
	amhs_dev_server* DevServer = new amhs_dev_server(m_io_service, endpoint);
	m_pServer = amhs_server_ptr(DevServer);
	m_thread = boost::thread(boost::bind(&boost::asio::io_service::run, &m_io_service));

	return 0;
}
开发者ID:JiangJunGG,项目名称:SyAutoH,代码行数:9,代码来源:AMHS_Server.cpp


示例20: requestUrl

void Provider::fetch(const Request &request)
{
    QUrl requestUrl(endpoint());
    requestUrl.setQuery(request.createQuery());

//    qDebug() << request.url() << requestUrl;

    d->manager->get(QNetworkRequest(requestUrl));
}
开发者ID:cloose,项目名称:qoembed,代码行数:9,代码来源:provider.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ endpwent函数代码示例发布时间:2022-05-30
下一篇:
C++ endmntent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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