Tag: 子网

在objective-c中,如果extern IP位于自己的子网范围内,则清理解决scheme以进行查找

大家好,我正在寻找一个更好的解决scheme来检查/计算IP地址是否在像你的iPhone一样的子网。 背景:我正在通过Zeroconf / Bonjour查找设备,这个设备可以有多个IP地址。 所以我想检查我的设备可以到达哪些设备。 我认为最简单的方法是采取外部IP连接与我的子网掩码,但我还没有find任何方法直接做(需要两个都是int),所以我提出了一个解决方法。 代码: #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include <ifaddrs.h> #include <netdb.h> #include <net/if.h> -(void)netServiceDidResolveAddress:(NSNetService *)service { NSLog(@" # # # Bonjour.netServiceDidResolveAddress # # # "); self.isConnected = YES; self.connectedService = service; NSLog(@"service.hostName : %@", service.hostName); NSLog(@"service.name : %@", service.name); NSLog(@"service.description: %@", service.description); // # # # // get MAC-ADDR […]

计算Objective-C中的广播地址

如何计算目标C中的广播地址? 我希望广播地址parsing为与以下子网计算器中显示的结果相同 – http://www.subnet-calculator.com/subnet.php 我有我的本地IOS设备和子网掩码的IP地址。 而且我知道广播地址使用下面的公式 broadcast = ip | ( ~ subnet ) (我正在回答自己的问题,因为我没有在互联网上看到过这些信息,而且我也没有意识到任何执行这个计算的程序库。很高兴看到其他人是否有更好的解决scheme或者知道任何库)