lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwip_close() doesn't work when lwip_write() hangs


From: Joel Cunningham
Subject: Re: [lwip-users] lwip_close() doesn't work when lwip_write() hangs
Date: Mon, 12 Oct 2015 20:16:12 +0000 (GMT)

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 

On Oct 12, 2015, at 02:19 PM, Sylvain Rochet <address@hidden> 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 and
select to achieve a similar behavior of having blocking I/O that can
be canceled. The trick here is adding a second socket to the read FD
set in select and then set select to block until your write or read is
ready. This second socket is bound to the loopback address. When you
want to cancel the blocking select from another thread, simply send a
datagram to the additional socket, which will return the select call.
Then you can detect that a cancel/wakeup happened because the second
socket 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
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]