Re: read/select not blocking on SSL socket?



On Aug 30, 1:20 pm, "yer...@xxxxxxxxx" <yer...@xxxxxxxxx> wrote:
I'm working on an SSL client/server application using persistent TLSv1
connections. I'm having some issues with my server and what I think
should be a blocking read or select.


I also understood Ruby io.read to be blocking.

I'm basically doing this where @io is an OpenSSL::SSL::SSLSocket:

until @data.length == READ_SIZE do
tmp = @io.read(READ_SIZE - @data.length)
if tmp.nil?
IO.select [@io]
else
@data << tmp
end
end

(I did not initially have the select call, but decided to give that a
try.)

I would expect that the read would block (I have not set O_NONBLOCK on
the socket) until there is data to be read. Instead, when there is no
data, every read call returns nil. I thought the select would fix
that, but it returns immediately and the read call again returns nil.

Am I misunderstanding how this should work? Would the fact that it's
an SSL connection cause the issue?

I'm using 1.8.4 on Linux.

Thanks for any insights you can offer.

Jeremy


Maybe I'm not the best person to be giving advice, but I don't think
your do/end is a legal Ruby construction.

I was under the impression you would use do/end like the following

sock.each_line do |line|
puts line
end

Notice the nifty | | thingies. This will read each line and then
return.


Chad

.



Relevant Pages

  • Re: read/select not blocking on SSL socket?
    ... connections. ... I also understood Ruby io.read to be blocking. ... I was under the impression you would use do/end like the following ...
    (comp.lang.ruby)
  • Re: Async socket & active connections
    ... You could argue that blocking affects ... The "blocking = true" in the disconnect phase seems to solve the ... The second thing I noticed is that the cleanup procedure for 0 timeout ... 300K connections, enough to start worrying... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: newsreader that doesnt require ISP account?
    ... Some will accept connections on ANY port. ... It seems to me like it wouldn't be a matter of specifically blocking NNTP ...
    (news.software.readers)
  • Re: Cannot send mail when using VPN
    ... It is a possibility that my work may be blocking something. ... external connections such as yours from sending mail and you may have to ... modify your account info to send mail via your work's SMTP server. ... >> I use a Cisco VPN client to log on to my work network. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: event driven framework for ruby
    ... >>That post suggests that the native thread running the ... > Ruby threads is not native threads. ... > I can see the entire process blocking with following script. ... packets transmitted, 0 packets received, 100% packet loss ...
    (comp.lang.ruby)