本文整理汇总了C++中Host::getPort方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::getPort方法的具体用法?C++ Host::getPort怎么用?C++ Host::getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::getPort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void MySQLClient::setup(Host& host, const string& user, const string& password, const string& db) //Setup connection, make DNS Req if necessary
{
init(); //Initialize client in known state, create socket
resetTimeout();
m_host = host;
if(!host.getPort())
host.setPort( MYSQL_PORT ); //Default port
m_user = user;
m_password = password;
m_db = db;
if( !host.getIp().isNull() )
{
connect();
}
else //Need to do a DNS Query...
{
DBG("DNS Query...\n");
m_pDnsReq = new DNSRequest();
m_pDnsReq->setOnReply(this, &MySQLClient::onDNSReply);
m_pDnsReq->resolve(&m_host);
DBG("MySQLClient : DNSRequest %p\n", m_pDnsReq);
}
}
示例2: bind
NetUdpSocketErr LwipNetUdpSocket::bind(const Host& me)
{
err_t err;
if(!m_pPcb)
return NETUDPSOCKET_MEM; //NetUdpSocket was not properly initialised, should destroy it & retry
#if LWIP_IGMP //Multicast support enabled
if(me.getIp().isMulticast())
{
DBG("This is a multicast addr, joining multicast group\r\n");
m_multicastGroup = me.getIp();
ip_addr_t multicastGroupAddr = m_multicastGroup.getStruct();
err = igmp_joingroup(IP_ADDR_ANY, &multicastGroupAddr);
if(err)
return NETUDPSOCKET_IF; //Could not find or create group
}
#endif
err = udp_bind( (udp_pcb*) m_pPcb, IP_ADDR_ANY, me.getPort()); //IP_ADDR_ANY : Bind the connection to all local addresses
if(err)
return NETUDPSOCKET_INUSE;
//Setup callback
udp_recv( (udp_pcb*) m_pPcb, LwipNetUdpSocket::sRecvCb, (void*) this );
return NETUDPSOCKET_OK;
}
示例3: bind
NetTcpSocketErr LwipNetTcpSocket::bind(const Host& me)
{
if(!m_pPcb)
return NETTCPSOCKET_MEM; //NetTcpSocket was not properly initialised, should destroy it & retry
err_t err = tcp_bind( (tcp_pcb*) m_pPcb, IP_ADDR_ANY, me.getPort()); //IP_ADDR_ANY : Bind the connection to all local addresses
if(err)
return NETTCPSOCKET_INUSE;
return NETTCPSOCKET_OK;
}
示例4: connect
NetTcpSocketErr LwipNetTcpSocket::connect(const Host& host)
{
if(!m_pPcb)
return NETTCPSOCKET_MEM; //NetTcpSocket was not properly initialised, should destroy it & retry
ip_addr_t ip = host.getIp().getStruct();
err_t err = tcp_connect( (tcp_pcb*) m_pPcb, &ip, host.getPort(), LwipNetTcpSocket::sConnectedCb );
if(err)
return NETTCPSOCKET_MEM;
return NETTCPSOCKET_OK;
}
示例5: SetUp
virtual void SetUp()
{
host1 = new Host("TestHost1", 2, &netSystem);
host2 = new Host("TestHost2", 2, &netSystem);
uint8_t mac1[6] = {0xBC,0xBC,0xBC,0xBC,0xBC,0xBC};
uint8_t mac1_2[6] = {0xCB,0xCB,0xCB,0xCB,0xCB,0xCB};
uint8_t mac2[6] = {0xCD,0xCD,0xCD,0xCD,0xCD,0xCD};
uint8_t mac2_2[6] = {0xDC,0xDC,0xDC,0xDC,0xDC,0xDC};
uint8_t ip1[4] = {192,168,0,7};
uint8_t ip1_2[4] = {192,168,0,8};
uint8_t ip2[4] = {10,0,1,4};
uint8_t ip2_2[4] = {10,0,1,5};
host1->setMACAddr(mac1, 0);
host1->setMACAddr(mac1_2, 1);
host1->setARPTable(mac2, ip2);
host1->setARPTable(mac2_2, ip2_2);
host1->setIPAddr(ip1, 0);
host1->setIPAddr(ip1_2, 1);
host1->setRoutingTable(ip2, 16, 0);
host1->setRoutingTable(ip2_2, 16, 1);
host2->setMACAddr(mac2, 0);
host2->setMACAddr(mac2_2, 1);
host2->setARPTable(mac1, ip1);
host2->setARPTable(mac1_2, ip1_2);
host2->setIPAddr(ip2, 0);
host2->setIPAddr(ip2_2, 1);
host2->setRoutingTable(ip1, 16, 0);
host2->setRoutingTable(ip1_2, 16, 1);
host1->getPort(0)->setPropagationDelay(TimeUtil::makeTime(1, TimeUtil::MSEC));
host1->getPort(1)->setPropagationDelay(TimeUtil::makeTime(1, TimeUtil::MSEC));
host2->getPort(0)->setPropagationDelay(TimeUtil::makeTime(1, TimeUtil::MSEC));
host2->getPort(1)->setPropagationDelay(TimeUtil::makeTime(1, TimeUtil::MSEC));
switchingHub = new Switch("Switch1", &netSystem);
switchingHub->addPort(host1->getPort(0));
switchingHub->addPort(host1->getPort(1));
switchingHub->addPort(host2->getPort(0));
switchingHub->addPort(host2->getPort(1));
switchingHub->addMACEntry(host1->getPort(0), mac1);
switchingHub->addMACEntry(host1->getPort(1), mac1_2);
switchingHub->addMACEntry(host2->getPort(0), mac2);
switchingHub->addMACEntry(host2->getPort(1), mac2_2);
ethernet1 = new Ethernet(host1);
ethernet2 = new Ethernet(host2);
ipv4_1 = new IPv4(host1);
ipv4_2 = new IPv4(host2);
interface = Target::allocate(host1);
interface2 = TCPSolutionProvider::allocate(host2, false, false, false);
interface->initialize();
interface2->initialize();
}
示例6: execute
void RoundRobinDistributor::execute() {
std::unique_ptr<HttpResponse> response;
Host *host;
while (1) {
std::unique_lock<std::mutex> lck(m_queue_mtx);
//std::cout << "waiting" << std::endl;
while (m_parsedRequests.empty()) m_queue_cv.wait(lck);
//std::cout << "notified" << std::endl;
m_requestTuple_t request = m_parsedRequests.front();
m_parsedRequests.pop();
lck.unlock();
host = &(cluster_nodes->at(request.host));
debug("Request send to host %s:%d", host->getUrl().c_str(), host->getPort());
response = host->executeRequest(request.request);
sendResponse(std::move(response), request.socket);
}
}