in reply to howto redirect STDOUT to $socket

Have a look at the post_accept() routine in Server.pm in the module Net::Server. You might even find Net::Server is exactly what you are looking for (as it has all the code for creating a daemon, and then switching the socket to STDIN/STDOUT before handing it to your callback function).

Something along the lines of:

if( defined $fileno ){ open STDIN, "<&$fileno" or die "Couldn't open STDIN to the client socket: $!"; open STDOUT, ">&$fileno" or die "Couldn't open STDOUT to the client socket: $!"; } else { *STDIN= \*{ $sock }; *STDOUT= \*{ $sock }; } STDIN->autoflush(1); STDOUT->autoflush(1);
(untested).