in reply to forking() flocking() on sockets

Child processes writing to a "shared socket" is a Bad Thing, and is probably best avoided. Apache manages to do this, but only with some very careful signal handling and locking, and even then, Apache is only trying to distribute the listen/accept component.

I would suggest making a parent process which handles the multiplexing of the sockets. Like perlipc recommends, you would create a pipe between the parent and each child process, and then later, read these and forward anything read out the main socket. The parent just multiplexes and the children do the actual work.

Use IO::Select and your job will be that much easier.

As a note, the reason you use syswrite instead of print is that syswrite is unbuffered, always, regardless of $|. If your output is buffered, there are occasions where each process only writes a portion of a line, and this can make for bad output data, such as "AAAAAAAA\nBBBBBBBB\n" becoming "AAAABBBBBBBB\nAAAA\n".