Does a receive timeout = -1 mean the thread doesn’t block at all? As opposed to timeout = 0, where (I believe I read in a prior post) the thread blocks indefinitely? Thanks!
I don’t think the TCPClient honors the timeout option. It will always wait for data. Use the available
property to see if it has any data ready. If it’s empty (0 bytes) & you call receive, it will block/wait for data to arrive.
Thanks Bill, I fully accept your response, but I think I didn’t frame my question in the proper context. Within the framework of a TCP plugin (eg TiVo or DenonAVR) I’ve seen the onPoll function implement “socket.receive(options)”, where in some cases options = {timeout:-1} Starting from basics, my question(s) are:
- Could socket.receive() still be considered a legitimate function call within onPoll? I’m not TCP-fluent, but I’m not sure how else to receive a TCP payload.
- If so, could options = {timeout:-1 } still be a valid parameter to pass into socket.receive(options).
- If so, what does options = {timeout:-1}, vs {timeout: 0} or {timeout: 250} accomplish?
Thanks again.
Regards, Terry
Sure, why not? That’s where it should be 99% of the time. Don’t bother setting the timeout
option because it doesn’t work. It will behave the same no matter which value you supply.
People sometimes get confused about how polling works. Read what I wrote here & should clear things up:
Works for me - thanks!