I want my app to react when it sees that a certain port is being listened to, and likewise when it stops being listened to.
Specifically, another app will start a gdb server (at 127.0.0.1
on 9003
) and I want mine to detect that. I don't really even care that it's a gdb server, just when the port is in use or not. I can do it right now using polling using a variation of this but that's not great for CPU wakes.
I'm wondering if I can use an NWConnection
(with no timeout) to monitor for these events (port in use, port no longer in use). If so, any pointers would be very gratefully received :) Even if just to say I'm barking up the wrong tree!