[Top][All Lists]

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

Re: [lwip-users] Clarification of LWIP and multi threading

From: address@hidden
Subject: Re: [lwip-users] Clarification of LWIP and multi threading
Date: Sun, 13 Feb 2011 16:10:27 +0100
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv: Gecko/20101207 Thunderbird/3.1.7

David Hammerton wrote:
closing a socket, whilest thread 1 is still using it for send/recv, which causes a problem - as yes, that would be a problem in any socket environment.
I think some socket environments support this. The result would be that the send/recv call returns with an error message "socket closed".
So the send there would be happening on the TCP thread (as a result of the message), is that safe to happen while you are reading on your read/write thread anyway? It must be, as if your read/write thread does a send() followed immedietly by a recv(), it's going to be the same thing.
No, the send() finishes (data copied into tcp_raw buffers) before it returns. The means the netconn's state reaches idle (or 'none' in the code) so it's free to acept a recv().
Ok. A little while ago I had an lwIP app that was written using the BSD socket layer, and this is exactly what I did. I had to modify the select() call to be able to pass in another object (representing a semaphore, really) that could be used to interrupt the select() call. I couldn't see any way of creating a socketpair() like object to interrupt the select() call. There is no built in way to do this with the BSD socket layer in lwIP, correct?
Yeah, that's a point currently missing with the basic select() implementation we have. Usually, you would just create a loopback socket and trigger it, although that's rather unperformant, too.
But for the netconn layer, I guess I can do my own thing. Is this (below)the correct way to do it?
Seems so, yes. Although there may be more arguments to your netconn_calback() than RECV_PLUS.


reply via email to

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