Ah, that worked!
Here is the working example:
#!/usr/bin/perl -w
use strict;
use IO::Socket::SSL;
my $port = 12345;
my $server = IO::Socket::SSL->new(
LocalAddr => '127.0.0.1',
LocalPort => $port,
Listen => 10,
Reuse => 1,
SSL_cert_file => 'cert.pem',
SSL_key_file => 'key.pem',
) or die "failed to listen: $!";
my $client = $server->accept;
*STDOUT = $client;
print "The client should see this STDOUT message.\n";
print $client "The client should see this SOCKET message.\n";
close($client);
The output I now see is as follows:
$ nc --ssl localhost 12345
The client should see this STDOUT message.
The client should see this SOCKET message.
Thank you!