Well, I just copied the code over from the question to illustrate, but ...
This ensures proper cleanup of child resources after child terminates. "When a process exits, its parent is sent a CHLD signal by the kernel and the process becomes a zombie until the parent calls wait or waitpid. If you start another process in Perl using anything except fork, Perl takes care of reaping your zombied children, but if you use a raw fork, you're expected to clean up after yourself." (from Camel, 3rd ed.). I don't know really if this is needed on Win32, but it is supported, since "wait() and waitpid() can be passed a pseudo-process ID returned by fork(). These calls will properly wait for the termination of the pseudo-process and return its status." (from ActiveState Perl docs).
This is probably not the best example code for writing servers and clients. Have a look at the Perl Cookbook, chapter 17.
Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com
In reply to Re: Re: RE: Sockets
by clemburg
in thread Sockets
by radagast
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |