TCPClient.connect() Blocking

Is TCPClient.connect() a blocking call? Sometimes it returns “immediately”, but other times it takes a fraction of a second or longer to return. If this is a blocking call, is there any way to make it asynchronous?

My user experience requires realtime processing of motion data, so any blocking call causing the system to become momentarily unresponsive kills the user experience. If TCPClient.connect() does block, is there another way to make HTTP requests over the local network without blocking the main loop?

TCP.connect() is indeed a blocking call as are most networking operations.

If you loop includes both blocking code and timing-critical code, the timing-critical code is best done off the main loop, either as separate thread or via a timer interrupt.


Thank you so much! I didn’t realize the Photon supported threading, and I hadn’t considered the Timer API for this use case. For now I think timers will be the simplest while still being effective. I really appreciate your help!