本文整理汇总了C++中IPAddress::getIP方法的典型用法代码示例。如果您正苦于以下问题:C++ IPAddress::getIP方法的具体用法?C++ IPAddress::getIP怎么用?C++ IPAddress::getIP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::getIP方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLocalAddress
void Connection::setLocalAddress(const IPAddress &addr) {
if (addr.getIP()) {
string ip(IPAddress(addr.getIP()).getHost());
evhttp_connection_set_local_address(con, ip.c_str());
}
if (addr.getPort()) evhttp_connection_set_local_port(con, addr.getPort());
}
示例2: service
void SocketServer::service() {
// Add listeners
SocketSet sockSet;
for (unsigned i = 0; i < ports.size(); i++)
sockSet.add(ports[i]->socket, SocketSet::READ);
// Add others
addConnectionSockets(sockSet);
if (sockSet.select(0.1) || connectionsReady()) {
// Process connections
processConnections(sockSet);
// Accept new connections
for (unsigned i = 0; i < ports.size() && !shouldShutdown(); i++) {
try {
Socket &socket = ports[i]->socket;
if (!sockSet.isSet(socket, SocketSet::READ)) continue;
IPAddress clientIP;
while (true) {
SmartPointer<Socket> client = socket.accept(&clientIP);
if (client.isNull()) break;
// Check access
if (!allow(clientIP.getIP())) {
LOG_INFO(3, "Server access denied for " << clientIP);
continue;
}
SocketConnectionPtr con = createConnection(client, clientIP);
client = 0; // Release socket pointer
if (con.isNull())
LOG_INFO(3, "Dropped server connection on "
<< ports[i]->ip << " from " << clientIP);
else {
connections.push_back(con);
LOG_INFO(3, "Server connection id=" << con->getID() << " on "
<< ports[i]->ip << " from "
<< IPAddress(clientIP.getIP()));
}
}
} CBANG_CATCH_ERROR;
}
}
示例3: addNameserver
void DNSBase::addNameserver(const IPAddress &ns) {
evdns_base_nameserver_add(dns, ns.getIP());
}