in reply to Daemon - Child - Client - Server

Basically this is a similar model of running that software uses often. One very close to it would be Apache for example.

When you fork off a child, it inherits all the parents handles, so what happens with the Apache example is
1) Main daemon listens on port 80
2) request comes in
3) Parent forks child to deal with request
3a) Child inherits all open filehandles and variables
4) Parent goes back to listening for requests
4a) Child processes request
5a) Child returns results
6a) Child wait x time prior to telling the Parent it is done with said request

While this isn't exactly technically accurate as to how Apache itself does it (as it maintains a pool of children to do its work, and only spawns more if its overloaded), its close enough for comparison.

Questions:
1) Is it worth it to queue the data up, or should you be processing real time streams?
2) How many "clients" are we talking about?
3) How far apart "logically" as well as "physically" are the "clients" and "servers"?
4) What is an acceptable timeout for client->server, server->client, server->server communication?

Yes it is possible to talk to a running process, provided the process has opened a 'socket' to deal with I/O. A socket can be a connection to a file, connection to the network stack, connection to a fifo or named pipe (which are really files, but we will ignore that for a sec and treat them differently), etc..

Named pipes are kinda cool. Alot of X applications make use of fifos in the /tmp or /var/tmp directory. Basically there is this handle they check, if there is data in the handle they slurp it in and process it, if not they go back to what they were doing and check back again later.

Personally I think your design is fine, and there are plenty of examples of forking servers, which is a fine search string to Super Search or Google for.

Hope that helps, and happy hacking

/* And the Creator, against his better judgement, wrote man.c */

Replies are listed 'Best First'.
Re: Re: Daemon - Child - Client - Server
by PyroX (Pilgrim) on Feb 14, 2003 at 20:31 UTC
    The web client may check back at any time between 5 seconds and 20 minutes, grab the que or buffered messages or actions and process them.

    The child needs to maintain the connection to the 3rd party server at all times until the web client hangs up.

    Initially we are talking about maybe 5 - 10 clients maximum. Later I would like to expand that to 25 or so.

    Named Pipes, I will be looking into the possibility of using that. I guesd files would be acceptable as well, the child could just amintain a file with the buffer and the web client can work with the file, this of course adds another component to the equation, but maybe less complexity.

    The 3rd party server is not very close, not local lan, not wan, but external to the network all-together. A timeout will not really be needed after connection, the child could notify the web client of the last buffer refresh and/or wether or not a update is needed. The only timeout here would be if the initial connection fails, or is lost later. Long periods of no data from the child is a possibility of course.

    I had looked at some postings here on perl web server daemons that fork to a child, and will probably start with that.

    Thanks for your help so far, everyone. All good info.