本文整理汇总了C++中IpAddress::copyFromInAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ IpAddress::copyFromInAddr方法的具体用法?C++ IpAddress::copyFromInAddr怎么用?C++ IpAddress::copyFromInAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IpAddress
的用法示例。
在下文中一共展示了IpAddress::copyFromInAddr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decodeMasterPacket
void ClusterMembership::decodeMasterPacket(const char *buf, int len,
const IpAddress & src)
{
// NOTE: Should we check the src address as being
// the master we know and love?
if (len < 21) {
// packet is too small to be a valid master packet.
return;
}
int numnodes = (int) (buf[20]);
// A master announcement is only helpful if there is at least
// one node in it, and fewer than the max
if ((numnodes < 1) || (numnodes > MaxNodes)) {
return;
}
// We need 12 bytes per node
if (len < (21 + (12 * numnodes))) {
// too small for the number of nodes.
return;
}
int newLower = 0;
int newUpper = 0;
const char *nodebuf = (buf + 21);
for (int i=0; i< numnodes; i++) {
int offset = (i * 12);
IpAddress ip;
ip.copyFromInAddr((struct in_addr *) (nodebuf+offset));
if (ip == localaddr) {
newLower = ntohl(*(int *)(nodebuf + offset + 4));
newUpper = ntohl(*(int *)(nodebuf + offset + 8));
}
}
setNewLocalBoundaries(newLower, newUpper);
}