Usually you wonβt be able to find out if a port is blocked unless you try to contact that port and get an answer, as far as I know, at least. However, you can determine if this port is being used. This method is used by GCDAsyncSocket to determine this case.
NSError *error = nil; if (![socket bindToPort:port error:&error]) { [self logError:[NSString stringWithFormat:@"Error binding port: %@", error)]]; return; }
The network has a lot of interesting and reliable approach.
source share