-
(long long) getInterfaceBytes { struct ifaddrs *ifa_list = 0, *ifa; if (getifaddrs(&ifa_list) == -1) { return 0; }
uint32_t iBytes = 0; uint32_t oBytes = 0;
for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) { if (AF_LINK != ifa->ifa_addr->sa_family) continue;
if (!(ifa->ifa_flags & IFF_UP) && !(ifa->ifa_flags & IFF_RUNNING)) continue; if (ifa->ifa_data == 0) continue; /* Not a loopback device. */ if (strncmp(ifa->ifa_name, "lo", 2)) { struct if_data *if_data = (struct if_data *)ifa->ifa_data; iBytes += if_data->ifi_ibytes; oBytes += if_data->ifi_obytes; } 复制代码
} freeifaddrs(ifa_list);
NSLog(@”\n[getInterfaceBytes-Total]%d,%d”,iBytes,oBytes); return iBytes + oBytes; }
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/101076.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...