Processes Communication Only with flags!

hello everybody and a happy new year!

i am trying the client-server model...i have no problem with sockets etc...
especially for server:there is a father who is listening for TCP connections from clients,the later send commands which parent shares to his children.
then children execute commands and send the results to each client through UDP connectionless communication...
my problem is that father,who read commands from clients,read them to a pipe and children processes reads them from there...the first free child must read command from a pipe to which parent is writing.

unfortunately we are not supposed to use thread-mutex-shared memory-
we only can use a flag which allows a child to read o command (message from father each time) and i don't know how to use that flag...
i must have a flag to a pipe and the first free process takes the flag read the message and puts back the flag...how can i do something like that?

i see that there is a need for such a flag because when i have one pipe
and e.g.:5 children let the parent write a command to the pipe
then we need only one child to read the whole command...which won't happen without a flag preventing other children from reading until the above child reads the whole command and put back the flag...

thanks a lot!

note:we have NUMCHILDREN children given as an argument.

This sounds like homework.

I suggest you look at UNIX semaphores.