My Quest for the Elusive Non-blocking SSL Client

I have been trying to construct an SSL client which works in non-blocking mode on a variety of platforms (i.e. it needs to run under UNIX (or Linux) and Windows). It uses a custom select dispatcher, which I am at this point unwilling to change (it would affect too much existing code).

I have looked at the following modules for implementing this client:

How I got Net::SSLeay to work

Being primarily a UNIX guy, I usually implement first on UNIX (in this case snow leopard), and then port to Windows. After much weeping and gnashing of teeth, I was able to get such a client working on my Mac using Net::SSLeay. The weeping and gnashing of teeth occured primarily not because Net::SSLeay is bad, or difficult, but because it isn't really well documented. In the process of implementation, here's what I arrived at:

References

The code which I "stole" off the web, came for the following source:

http://devpit.org/wiki/OpenSSL_with_nonblocking_sockets_(in_Perl)

Since I was writing a client and his sample code was for a server, I didn't use much of his code, but the magical incantations were useful. I didn't implement his "drain the socket on read strategy", because the server always closes when its finished writing and "read" always selects true on a closed socket, so I don't have to worry about orphan data in the SSL buffer.


In reply to Quest for the Elusive Non-Blocking SSL Client by bill.bbennett

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.