TCP port scanning?

I have an iOS app that will communicate with a bluetooth device via TCP. One issue we are having is that common ports like 8080 are blocked on some networks. Do you think it would be possible to create a method that scans for open ports if the "starting port" is blocked? If so, what would that look like with psuedo code?


1. Start function to scan and find up to 5 (can be any number really) open ports

2. Create a tcp connection starting at port 8000

3. If connection successful, add to array of successful ports

4. If connection fails, add to array of failed ports

5. Check if successful array has 5 items

6. If yes then stop loop

7. If no then repeat steps 2-7


This could all be done on a background thread with GCD, yes?

Is this something that would get an app declined for the App Store?


Thanks in advance!

Replies

A problem is the time required because of the timeout for each test.


Could this help (sending a Terminal command from the app):

h ttps://community.cisco.com/t5/switching/any-way-to-test-tcp-port-from-ios/td-p/1283333