本文整理汇总了C++中Host::getIp方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::getIp方法的具体用法?C++ Host::getIp怎么用?C++ Host::getIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::getIp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: on_master_event
void SyncedSDFileSystem::on_master_event(TCPSocketEvent e) {
debug("MASTER: got event: %d", e);
TCPSocketErr err;
Host slave;
TCPSocket *slave_socket;
MasterNodeHandler *dispatcher;
switch (e) {
case TCPSOCKET_ACCEPT:
debug("MASTER: accepting new connection");
err = tcp_socket_->accept(&slave, &slave_socket);
if (err) {
// TODO: handle errors
}
debug("MASTER: creating new handler");
dispatcher = new MasterNodeHandler(this, slave, slave_socket);
node_handlers_.insert(pair<string, MasterNodeHandler *>(ip_to_string(slave.getIp()), dispatcher));
// dispatcher should destroy self when done or disconnected
break;
case TCPSOCKET_CONTIMEOUT:
case TCPSOCKET_CONRST:
case TCPSOCKET_CONABRT:
case TCPSOCKET_ERROR:
case TCPSOCKET_DISCONNECTED:
// TODO: handle errors
break;
case TCPSOCKET_CONNECTED:
case TCPSOCKET_READABLE:
case TCPSOCKET_WRITEABLE:
default:
// these should never happen
break;
}
}
示例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;
}