Boost logo

Threads-Devel :

From: Marco De Paoli (depaolim_at_[hidden])
Date: 2007-06-11 03:17:51

look at this

the article is a good introduction to Boost Thread concepts
for your needs use concepts described in paragraph 1 and 2 (listing 1, 2 and
optionally 3)


2007/6/11, attoo_at_[hidden] <attoo_at_[hidden]>:
> Greetings, my name is Emanuele.
> I am not very good at C++ (I am still studying) but I was asked to setup a
> multithreaded server on a Redhat Linux system, threads should be concurrent
> on a common resource.
> My idea is to open a new thread for each new client that connects to the
> server, lock the common resource, use it, unlock it and return back results
> to each client correctly.
> At the very beginning I thought to do it with C syntax, forking a new
> process for each new client.
> It worked, but because of the common resource, results are returned in the
> wrong way, not in the correct order.
> This is the idea of what I wanted to do:
> //parent process
> while(1){
> int conn=accept(listen_sd,........);
> if( fork()==0 ){ //child process
> close(listen_sd);
> //reading from conn
> //elaborating received data, through a common resource, to be
> "mutexed"
> //sending results to conn
> }
> //parent process
> close(conn);
> }
> Is there a way to do it with Boost::thread? One thread for each client,
> with synchronization on the common resource?
> If yes, could you possibly tell me how to do it for real, at least in the
> basic lines?
> Thank you for your effort and patience
> _______________________________________________
> threads-devel mailing list
> threads-devel_at_[hidden]

Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at