parallel, concurrent server with Boost::thread

cpp Japan
  • 13 years ago
    Greetings to everyone...
    This is my first message in this forum and I have a very short experience in C++.
    This said, I would like to setup a server that accept strings from many clients, elaborates those strings and send them back to each client, in the correct way.

    The elaboration is done through and external program, that I have to call with "execl", this is compulsory. So this program is a shared resource that should be "mutexed", in order to avoid wrong order in messages.

    With a simple C syntax, I would like to so something like this:

    Code: ( text )
    1. //parent process
    2. while(1){
    3.         int conn=accept(listen_sd,........);
    4.  
    5.         if( fork()==0 ){  //child process
    6.              close(listen_sd);
    7.              //reading from conn
    8.              //elaborating received data, through a common resource, to be "mutexed"
    9.              //sending results to conn
    10.         }
    11.            
    12.         //parent process
    13.         close(conn);
    14. }


    The basic idea is to open a new thread for each new client connected, and every thread has to be independent and to be synchronized to the common resource.

    Is there someone so kind and powerful who could help me in a practical and easy way?
    (I am sorry but I'm using C++ only for 4 month and many things are still so hard Sad [:(] )

    Thank you all for your attention
    EMA















Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor