Timer with socket
#10793
Replies: 2 comments 6 replies
-
The timer callback function requires an argument, which is the timer object. You can ignore it in the function, but itusz ne present.
|
Beta Was this translation helpful? Give feedback.
2 replies
-
One option is to use socket.setblocking to set the socket for non-blocking operation. Then loop doing recv, sleeping and testing time elapsed until you have received all 1024 bytes sent by your server or the maximum time has exceeded. Or take a look at socket.settimeout if supported on your port (https://docs.micropython.org/en/latest/library/socket.html). |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with this little program.
It's an ESP8266 client that connects to a server over wifi.
But if the server has not configured its socket, the client remains stuck on com_net.recv(1024). (line 32)
I was thinking of putting a timer that would unlock after 5 seconds, but I got this error TypeError: function takes 0 positional arguments but 1 were given.
When I do Ctrl-C after 10 seconds, I have File stdin, line 32, in module
KeyboardInterrupt:
Which shows that com_net.recv is blocking. Since there is no error message, I cannot circumvent the problem with a Try/Except.
Do you have a solution for me?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions