Correct method for non-blocking socket acceptance #10942
Unanswered
dereknbartram
asked this question in
RP2040 / Pico
Replies: 1 comment 2 replies
-
I believe this example could be of help https://github.com/peterhinch/micropython-async/blob/master/v3/as_drivers/client_server/userver.py |
Beta Was this translation helpful? Give feedback.
2 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.
-
Hi,
What's the correct way to determine if sockets are pending?
This is essentially what I'm trying to achieve: if a connection is available, accept it and do stuff with it, otherwise do other stuff. The 'other stuff' requires as much processing time as possible, so I don't want to sit waiting for timeouts. In C# the TcpListener class has a 'Pending' property which indicates if 'accept' has anything to do, but I cannot find anything corresponding to that in micropython
The only option I have found is:
The accept call then terminates with None if no socket pending, but if I set that sufficiently short, I'm finding when actually processing valid connections they then timeout - it's like the timeout applies to the complete life of the socket and not just 'acceptance'. I've tried setting tcp_socket.settimeout(0) and cl.settimeout(0.5) was similar issues.
Beta Was this translation helpful? Give feedback.
All reactions