in reply to Win32: Redirect STDOUT to socket

What you have is a buffering problem. You have to turn autoflushing on for the new STDOUT file handle you make:

use IO::Handle; # up top ... open STDOUT, '>&', $WRITE or die "failed redirect to STDOUT: $!"; STDOUT->autoflush(1); ...

Or you can use the perlvar $|, aka $OUTPUT_AUTOFLUSH

use English qw(-no_match_vars); ... open STDOUT, '>&', $WRITE or die "failed redirect to STDOUT: $!"; $OUTPUT_AUTOFLUSH = 1; ...

I almost mentioned the select builtin but it gave different output, interestingly!

Replies are listed 'Best First'.
Re^2: Win32: Redirect STDOUT to socket
by repellent (Priest) on Feb 09, 2009 at 08:24 UTC
    Doesn't work for me. After trying your suggestions, it still stalls. I have tried placing after open:
    use IO::Handle; STDOUT->autoflush(1);

    and even
    select((select(STDOUT), $| = 1)[0]);

    to no avail.