lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] about lwip_close() and lwip_connect() problem


From: Kieran Mansley
Subject: Re: [lwip-users] about lwip_close() and lwip_connect() problem
Date: Tue, 20 May 2008 13:48:09 +0100

Replying to list as others may find this useful.  Please do the same.

On Tue, 2008-05-20 at 19:49 +0800, xcbman wrote:
> The same socket in different threads, Are all socket function(connect
> ()\recv()\send()\close()) must be protected against concurrent
> access?? Or just connect() and close() function need to protected
> against concurrent access? Is Lwip later version can resolve different
> thread use the same socket?

Probably safest to assume that all socket operations must not be used
concurrently on the same socket from different threads.

> Is there any way instead socket layer function to resolve concurrent
> access? thank you for help.

You could have a lock, and use that to protect against concurrent
access.  Or you could write your program so that you know it won't
happen this way.  For example, it's common to have a thread that does
the listen and accept of new connections.  This will then hand the
connection over to another thread to do the data transfer.  The socket
is used from two threads, but not at the same time, and so there's no
problem.

Kieran





reply via email to

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