I’m writing some server code that talks to a client process via STDIN. I’m trying to write a snippet of perl code that asynchronously receives responses from the client’s STDOUT. The blocking version of the code might look like this:
sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { print STDOUT $line; } return; }
Importantly, the snippet needs to work in Win32 platform. There are many solutions for *nix platforms that I’m not interested in. I’m using ActivePerl 5.10.
This thread on Perlmonks suggests you can make a socket nonblocking on Windows in Perl this way:
More details and resources in that thread