TCPClient.connect() blocks - how to "unblock"?

The blocking nature of TCPClient.connect() is a well documented issue in the forum, specifically the hardcoding of the timeout.

Am testing a corner case of using a bad IP address and this is giving a 5 second blockage (as expected).

To work around this long blockage, I tried setting a timer that kicks off after 250 mS just before the call to .connect(). The timer callback calls TCPClient.stop(), hoping that this would circumvent the block, but it does not.

@rickkas7 has some great posts on this issue:

but I wanted to see if I could fix the issue using the timer work around.

I’d just try it and see. I give it maybe a 50% chance of working. The inside of the connect call of synchronous, but there isn’t a guard mutex around it, so maybe you can interrupt it. But it’s deep in the bowels of WICED and the code is hard to follow so I’d just try it and see if you can interrupt it.

1 Like

@Rickkas7, I can confirm that the timer strategy definitely does not work! This is not surprising as you say because of the plumbing.

Am wondering if it makes sense to have a system call like TCPClient.terminate() or similar so that one could implement this strategy?