This didn't work for me:
my $client = $server->accept; open(STDIN, "<&=", $client) || die "Couldn't dup client to stdin"; open(STDOUT, ">&=", $client) || die "Couldn't dup client to stdout"; print "The client should see this STDOUT message.\n"; print $client "The client should see this SOCKET message.\n";
What I see is this:
$ nc --ssl localhost 12345 The client should see this SOCKET message

Before I was using "nc --ssl host port", I was using "openssl s_client -connect host:port" for my testing. I got all the certificate info at the beginning of the output and I didn't see anything that helped. I would love to know what you saw in the openssl output that clued you in on the file descriptor. In any case, changing my script to your suggestion doesn't change anything for me.

On a similar note: I was reading up on IO redirection in Perl and it doesn't seem surprising that system() and exec() continues to use the standard STDIN/STDIO/STDERR file descriptors. The redirection in Perl stays within perl and doesn't carry forth externally. It may be possible to use FileHandle or Tie::Handle to get it to work, but since using an command pipe with open() seems to work, it doesn't seem worth the extra effort. It works with POE as well.

Mostly, I am bummed by the fact that IO::Socket::SSL acts differently from IO::Socket::INET. I can't get any redirection working at the moment. I at least have something working with Net::Server and with POE.


In reply to Re^2: IO::Socket:SSL and Net::Server STDOUT redirection by Zucan
in thread IO::Socket:SSL and Net::Server STDOUT redirection by Zucan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.