> That sample code is where my code changes came from

Please look closer at the example code in IO::Socket::SSL you've based your code from. The example code is specifically dealing with the case that there are still buffered data (using pending) before calling can_read again. Your code misses this part. While the code then will work for cases where each websocket frame is in its own SSL frame it will spuriously fail in case multiple websocket frame are contained in one SSL frame.

> Before I made the change, it would get caught in a loop without reading any new data, I'm guessing because SSL needed to be renegotiated like I read in the doc I did find...

In your first code you made the socket non-blocking but then did not check for the socket to be readable at all (can_read) and instead run a busy loop where it always tried to read from the socket and most times immediately failed with EAGAIN since no data where available on the socket. Adding the can_read fixed this but introduced the problem that you don't deal properly with multiple websocket frames inside a single SSL frame. The part about renegotiation instead (i.e. dealing with SSL_WANT_WRITE) is probably unused in most cases since usually no renegotiation will happen on the socket.


In reply to Re^4: WebSocket idle by noxxi
in thread WebSocket idle by chris212

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.