It's a great trick, hopefully others can leverage it as well :)
I'm not sure what I'd do without it. Having select() and non-blocking sockets operate as the blocking construct of a server's event loop is essential for managing multiple connections in a high performance manner.
Joel
I'm not sure what I'd do without it. Having select() and non-blocking sockets operate as the blocking construct of a server's event loop is essential for managing multiple connections in a high performance manner.
Joel
On Oct 12, 2015, at 02:19 PM, Sylvain Rochet <[email protected]> wrote:
Hi Joel,
On Mon, Oct 12, 2015 at 07:10:39PM +0000, Joel Cunningham wrote:You can use SO_SNDTIMEOUT, which should work on LwIP 1.4.1. I have used it in my port with LwIP 1.4.1, so possibly there's a problem with your port?I've also written applications that used non-blocking sockets andselect to achieve a similar behavior of having blocking I/O that canbe canceled. The trick here is adding a second socket to the read FDset in select and then set select to block until your write or read isready. This second socket is bound to the loopback address. When youwant to cancel the blocking select from another thread, simply send adatagram to the additional socket, which will return the select call.Then you can detect that a cancel/wakeup happened because the secondsocket is marked as ready.
I really like this trick. It remembers myself of the well known wake up
pipe I explained here[1], but using the loopback to do so in lwIP is
very very clever :-)
Sylvain
[1] http://lists.gnu.org/archive/html/lwip-devel/2015-09/msg00028.html_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users
signature.asc
Description: PGP signature
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
