Hi there,
I don’t think you should place this code within a loop (such as a repeating timer.performWithDelay), especially at a frequency of one second. If the socket takes more than one second to open and close, you’ll be opening more and more sockets to the same host, which is bad.
Instead, in my experience it’s worked well simply to wrap it in a function and call it to test network availability before critical user actions (such as attempting an IAP, attempting to share on social media, etc.), and alerting them if they don’t have a network connection.