On Wed, 2008-10-29 at 09:10 -0700, Drago wrote:
> Hello, I am interested whether I can do connect() from different
> threads concurently.
> I found that doing close() from different threads on same fd, does
> nasty things, so ..does it applies to connect() ?
> Is it possible connect() to return same fd to concurent threads?
> Does libc has any concurency protection, if does ..from when? I am
> using is rather old libc-2.3.5.
> Or I just have to protect with mutexes all syscall functions?
> Thank you very much, in advance
>
> Dragomir


To supplement what other posters have said:

Don't lose sight of the fact that all the threads are part of the *same*
process. They therefore share the same address space and the same set of
file descriptors.

If you want proper isolation you must use separate *processes*, not
threads, i.e. call fork() not pthread_create(). You will then have total
isolation and can do what you like. The flip side is that communication
between processes is trickier than between threads.