lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] TCP socket thread safety


From: Simon Goldschmidt
Subject: Re: [lwip-users] TCP socket thread safety
Date: Tue, 12 Feb 2013 08:09:56 +0100

Shaun Crampton wrote:
> I'm looking at lwIP for a new project and I'm trying to understand the
> threading model for the socket-alike API.  Assuming I'm on a preemptive OS
> (Linux), is it safe to
> 
>   *   concurrently create multiple sockets in different threads

Yes.

>   *   for one single socket, call send in one thread and recv in another
> thread (to enable duplex communication).

No.

> If it's not possible to do duplex communication in that way, is there a
> way to do it?
> 
> If I've read the docs correctly, then I think it's up to my application to
> stop all threads using the socket before closing it, which is fair enough.

That way it would work, but it's not real full duplex then. It's quite hard to 
make a thread return from recv() once it's blocked there waiting for new 
data... You can always use select(), but there's no easy way (other than a 
loopback socket) to make select() return by application software if you're not 
using a timeout...


Simon



reply via email to

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