lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Socket API thread safe?


From: Wilfred Hoogerbrugge
Subject: RE: [lwip-users] Socket API thread safe?
Date: Tue, 8 Jun 2004 14:38:50 +0200

> From: K.J. Mansley
> Sent: dinsdag 8 juni 2004 14:20
>
> On Tue, 2004-06-08 at 12:28, Wilfred Hoogerbrugge wrote:
> > Hello group,
> >
> > As the subject already shows I wonder if the lwIP socket API is
> multi thread
> > safe.
> >
> > I remember having read somewhere it is, but can¢t find that
> statement back.
> >
> > As I¢m hunting a race condition in my environment using lwIP +
> socket API, I
> > wonder if the problem my lay in the fact I¢ve two threads
> calling the socket
> > API (one for sending using sendto and one for receiving using recvfrom).
>
> Are you using the same socket from two different threads?  Most sockets
> API (lwIP included) do not guarantee the behaviour you might be hoping
> for: it's just like any other shared resource - you need to protect it
> from concurrent access with mutexes.  The best course would be to
> serialise your access to each socket through a single thread.
>
> Kieran
>

Yes, I do use the same socket from both threads.
I (maybe a little naive) hoped for the socket API to make this possible.

If this is not guaranteed to work (no, I don't have any doubts about your
comment on this, it's just new for me) I will think about using a single
thread to serialize things. Or maybe I will use different ports for sending
and receiving.

Thanks!

Wilfred





reply via email to

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