Summary
Available options to specify the timeout amount for the receive function.
Description
- Following the Publish/Subscribe Tutorial.
- Unable to specify the timeout amount and program just hangs waiting for the message.
Resolution
The recv() method has three ways of being called:
- recv() or recv(-1) - blocks indefinitely until a new message is received.
- recv(0) - returns immediately if no message is received.
- recv(timeout) - waits for the specified timeout to receive a message.
- For example, recv(timeout=1000) will wait for 1000 milliseconds.