Boost logo

Threads-Devel :

From: attoo_at_[hidden]
Date: 2007-06-10 21:13:42

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
        int conn=accept(listen_sd,........);
        if( fork()==0 ){  //child process
             //reading from conn
             //elaborating received data, through a common resource, to be "mutexed"
             //sending results to conn
        //parent process
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 list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at