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 )
-
//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);
-
}
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
)
Thank you all for your attention
EMA
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).