Hi monks,

I made a STARTTLS application, that is to timeout eventually and does roughly:

$fh = IO::Socket::INET->new(%arg); IO::Socket::SSL->start_SSL($fh , %opts); # this is the snippet to fetch new data $bits = ''; vec($bits, fileno($fh), 1) = 1; if(select($bits, undef, undef, $timeout)) { $len = sysread($fh, $buf, 200, length($buf)); } else { die "timeout: $!\n"; }

the buffer size "200" is used just as example here. The protocol is not line-based and may contain arbitary 8bit data.

I have the problem, that when the server sends a packet larger than 200 bytes immediately after the SSL handshake while reading the server greating, select() succeeds exactly once, the second call of select() simply stalls, but it should rather return true, because of the remaining stuff in Net::SSLeay's buffer, I think.

Another user has the problem with a buffer size of 2048, which was my default actually, later in the operation and not just right after the SSL handshake. Presumly that particular communication produced a pending buffer of more than 2048 byte.

To work around I will probably code a loop around sysread() to fetch all data available at the particular time. Maybe a large read size, say 32KB as this is the buffer size in Net::SSLeay, will do the trick as well.

But, am I really wrong to assume select() is to return true in this case? Or is there another way to have a working timeout in sysread()/syswrite()? $fh->timeout(num) in blocking mode does not work.

my versions of IO::Socket::SSL v1.31, Net::SSLeay v1.30

Regards, ska


In reply to IO::Socket::SSL's select() ignores pending data by ska

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.