lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2011/7/16 Gaspard Bucher <gaspard@teti.ch>:
>   1. Receive message from network ===> update state ==> post reply

You can check out copas[1], a network library based on luasocket[2]
that uses coroutines to handle connections in a quasi-parallel manner.
In effect, you'll have to fall back to polling - your coroutines must
yield from time to time and the scheduler (your code that manages the
coroutines) must distribute the events after having polled them. For
copas, it works very well and it is one of my most favorite libs. A
way to approach this topic can also be to use native threads in your
host environment to receive and collect the events that the thread is
listening on. The coroutine scheduler unqueues the events and passes
them on.

[1] http://keplerproject.github.com/copas/
[2] http://w3.impa.br/~diego/software/luasocket/