[Top][All Lists]

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

Re: [lwip-users] the sequentiality of the lwip stack

From: Martin Velek
Subject: Re: [lwip-users] the sequentiality of the lwip stack
Date: Mon, 24 Mar 2014 11:06:36 +0100


>Can someone provide a common situation which requires one socket used on 
>multiple threads?
I have wrote a simple serial/ethernet converter using RTOS. There was
one thread A receiving data from socket So and the second B receiving
data from serial port SP.

A reads data (passive waiting) from So, A sends received data to SP.
B reads data (passive waiting) from SP, B sends received data to So.

I believe there are many techniques how to solve it but this was the
simplest one. I was also lucky, the socket was UDP. With LWIP I was
able to use the So in both threads. It is not quite true that you
cannot use one socket in e.g. two threads simultaneously. There is
some info and restrictions about using socket in multiple threads  on


On Wed, Mar 19, 2014 at 2:49 PM, Pomeroy, Marty
<address@hidden> wrote:
>  >>  BUT never can t1 and t2 both access s1 or s2.
> Practically speaking, a socket is a stream of data, and it doesn't make
> sense for tasks to contend for that stream.  You would need to provide
> additional coordination mechanisms at the application level to make sure t1
> is not getting t2's data from s1, and vice versa.  If you are providing that
> coordination mechanism at the application level to prevent data contention,
> then there will be no problem in the stack anyway.
> The only situation I can think of where this might be "useful" would be a
> socket that the application never receives from and only sends to.  So it
> might be "nice" to send on one socket from multiple threads.  But you can
> provide a simple coordination mechanism to keep the requests single
> threaded.  Or just open two sockets.
> Can someone provide a common situation which requires one socket used on
> multiple threads?  If not, given the effort that would be needed, the lack
> of requirement, and the simplicity of working with lwIP as it is...
> Marty
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

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