From: Tony Arcieri Date: 2013-01-31T05:07:09+09:00 Subject: Re: SSLSocket in non-blocking mode --f46d0434c0acef193304d486f20f Content-Type: text/plain; charset=ISO-8859-1 Are you not aware OpenSSL::SSL::SSLSocket has a #read_nonblock method? On Wed, Jan 30, 2013 at 11:52 AM, Brian Modra wrote: > I've done some more work on this since posting, and tested out an idea I > hinted at in my previous post: > I check the underlying tcpsocket (@sock in my code) using IO.select. > (Actually I call select passing it an array of the currently connected > tcp sockets, and if there are any bytes waiting, then if I call sysread > on the SSLSocket, it will fill its input buffer from the tcpsocket, > decrypt them, and return them. > So I guess I answered my own question. > > Also, it seems logical to me now that #pending will actually only tell > me how many bytes are remaining in the output buffer of the SLSocket, > because the SSLSocket won't read from the tcpsocket unless its buffer is > -empty-. I.e. when #pending is returning zero :) > So I have to be optimistic, read one byte (only when I know, from the > call to IO.select, that there are bytes ready for it to process)... > which will trigger it to read from the TCPSocket, and decrypt it, and > fill its output buffer, and then #pending will be non zero. > > I'm making assumptions here, and would be grateful if someone can > provide an authoritative answer. > > -- > Posted via http://www.ruby-forum.com/. > > -- Tony Arcieri --f46d0434c0acef193304d486f20f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Are you not aware OpenSSL::SSL::SSLSocket has a #read_nonb= lock method?


On Wed, Jan 30, 2013 at 11:52 AM, Brian Modra <lists@ruby-forum.co= m> wrote:
I've done some more work on this since p= osting, and tested out an idea I
hinted at in my previous post:
I check the underlying tcpsocket (@sock in my code) using IO.select.
(Actually I call select passing it an array of the currently connected
tcp sockets, and if there are any bytes waiting, then if I call sysread
on the SSLSocket, it will fill its input buffer from the tcpsocket,
decrypt them, and return them.
So I guess I answered my own question.

Also, it seems logical to me now that #pending will actually only tell
me how many bytes are remaining in the output buffer of the SLSocket,
because the SSLSocket won't read from the tcpsocket unless its buffer i= s
-empty-. I.e. when #pending is returning zero :)
So I have to be optimistic, read one byte (only when I know, from the
call to IO.select, that there are bytes ready for it to process)...
which will trigger it to read from the TCPSocket, and decrypt it, and
fill its output buffer, and then #pending will be non zero.

I'm making assumptions here, and would be grateful if someone can
provide an authoritative answer.



--
= Tony Arcieri
--f46d0434c0acef193304d486f20f--