I would like to process UDP and TCP data in an async manner.
What is the recommended approach with in micropython for esp8266.
I was unable to import select/poll and I didn't see SO_NONBLOCK so dont think I can
just poll the sockets myself in a non blocking way. Ideas?
esp8266 async sockets
Re: esp8266 async sockets
The microcontroller does not have a multitasking operating system, so it's ok to enter a busy-waiting loop checking the sockets and anything else that needs checking.
You can do that under an OS (e.g. Linux) too, but it uses CPU time that other tasks could use, which is why it's generally discouraged. Also for a large number of sockets it can be inefficient.
On the ESP neither of these things matter, because you can't have many sockets anyway, and there are no other tasks.
---
Actually there's another method entirely which the webrepl.py uses - setsockopt(socket.SOL_SOCKET, 20, handler) - but this is undocumented so I guess it might go away if webrepl stopped using it.
You can do that under an OS (e.g. Linux) too, but it uses CPU time that other tasks could use, which is why it's generally discouraged. Also for a large number of sockets it can be inefficient.
On the ESP neither of these things matter, because you can't have many sockets anyway, and there are no other tasks.
---
Actually there's another method entirely which the webrepl.py uses - setsockopt(socket.SOL_SOCKET, 20, handler) - but this is undocumented so I guess it might go away if webrepl stopped using it.
Re: esp8266 async sockets
select.poll isn't yet implemented for esp8266.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/