Outbound port blocking detection

I am working on an application using AsyncSocket .

Is there a way to check if a particular port is blocked by a firewall?

+4
source share
1 answer

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.

0
source

Source: https://habr.com/ru/post/1384838/


All Articles