in reply to Re: Daemon with Net::Daemon
in thread Daemon with Net::Daemon

Why do you not like fork for situations like this? To me it seems like the perfect tool to create little child processes. Also although I hate to point out the obvious the 'server' I posted above has maybe five times less code, making it substanially easier to read and write.

Replies are listed 'Best First'.
Re: Re: Re: Daemon with Net::Daemon
by Preceptor (Deacon) on Sep 03, 2003 at 13:06 UTC
    I dislike the idea of duplicating the entire process for something simple like printing a response to the socket. Fork is know as a heavyweight process for a reason. (yes, I know that copy-on-demand alleviates this)

    I also rather like showing off an example of one of the other ways to do it, which becomes useful in some of the situations where a fork is not.

    As ever, there's more than one way to do it. Fork can be effective and simple, but IO::Select allows one some better control over child processes.

    I've never actually profiled the code, but I'd imagine that fork works pretty good on Unix, where it's integral to the OS. (Ish, because it becomes a little fuzzier when you're talking about forking perl, and the interpreted code) I'd not be so sure about doing so on Windows.

    Has anyone tried a benchmark of the relative methods?