I need to check if some ports
(8888 and 8889) are open in a private network
(196.168.xxx.xxx).
I have tried to bind
the port
, but I always get the same result either if the port
is open or not (I have 2 networks
with different configurations for testing)
GCDAsyncUdpSocket *_udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSError *error = nil;
BOOL b = [_udpSocket bindToPort:8888 error:&error]
I've also tried this code from here:
size_t len = 0;
if (sysctlbyname("net.inet.tcp.pcblist_n", 0, &len, 0, 0) < 0) {
perror("sysctlbyname");
} else {
char *buf = malloc(len);
sysctlbyname("net.inet.tcp.pcblist_n", buf, &len, 0, 0);
NSData *data = [NSData dataWithBytesNoCopy:buf length:len];
NSLog(@"data = %@", data);
}
But I don't know how to work with the response
.
Any idea? I think the problem is that I'm not sure about what I'm looking for.
Thanks!