lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Multithreading


From: Craig Graham
Subject: Re: [lwip-users] Multithreading
Date: Tue, 11 Apr 2006 11:15:41 +0100
User-agent: KMail/1.8

On Tuesday 11 April 2006 09:28, Kieran Mansley wrote:
> On Tue, 2006-04-11 at 09:53 +0200, Julika Burger wrote:
> > Hi,
> >
> > I have a question about lwip.
> > Is lwip really multi threading able?
> > Is it possible to open two sockets at the same time and read and write
> > data to them?
> > We use the PSOS Operating system and I can not control if two threads at
> > the same
> > time use a socket or not.
>
> No.  To be honest, the sockets API doesn't really allow you to do that
> in any meaningful way on other operating systems either.  You need to
> add a mutex to protect access to the socket and use that so that only
> one thread is using it at any one time.
>
> Kieran

I think what Julika was trying to ask was can two threads open two separate 
sockets and both threads use their own sockets (rather than can two threads 
access the same socket). And the answer to that question is, of course, yes.

It's also worth noting that although only one thread can read from a socket, 
there's actually no reason why (at least using the BSD emulation API) several 
threads can't refer to a write handle on a socket at once - for example, if 
you're running a debug console over telnet and several threads output debug 
messages to the console. Ok, it's probably "cleaner" to have a debug server 
thread routing from a message queue to the socket for you, but having several 
threads write to the socket will also work (I've tried it).

Laters,
Craig.




reply via email to

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