Hi,

From: "rakaur" <rakaur / gmail.com>
>
> I've been having issues using Ruby, select, and the OpenSSL library.
> I've heard from a few people "use threads! Ruby breaks select because
> threads rock!" I'm not going to use Ruby's threads, because they're not
> real and I don't like them. So, neener.

I myself look forward to the day when Ruby supports native OS threads.

However, there's nothing unreal about Ruby's green threads.  Consider
this: You are already using ruby's threads, period.  You may not 
choose to create *additional* threads, but you're always running at
least one thread.  And when you call select(), from your main
thread, ruby calls rb_thread_select() which in turn calls 
rb_thread_wait_for() and rb_thread_schedule(), to handle it the
same as any number of ruby threads making select() calls.  You're
always using Ruby threads, calling select() from any thread always
goes through the same mechanism.  (So, neener ;D)

Search for rb_thread_select if you'd like to look at the implementation:
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/eval.c?rev=1.616.2.142
(1.616.2.142 is v1_8_4)

> I can implement simple TLS clients/servers (ie, proof of concepts) just
> fine, but when I try to turn a plaintext XMPP stream into a TLS stream
> I get errors.
> 
> I'm implementing an XMPP server in Ruby (or rather, trying to). XMPP
> (aka Jabber) starts out plain text, and if the ability to do TLS is
> advertised switches to that. Using the exact same code that works in
> simple proof-of-concepts, I repeatedly get "no shared cipher" from the
> server's side, and "wrong version number" from the client's side. Due
> to the complete and utter lack of documentation excluding test/openssl/
> in the Ruby source, I have no idea what these errors mean or how to go
> about fixing them.

Yeah I would definitely donate $$ toward a ruby OpenSSL cookbook
project.  

I'm wondering, what does it mean to "turn a plaintext XMPP stream
into a TLS stream" in code?  I mean, if your proof-of-concept 
programs work, but this dynamic switching doesn't work - what does
the code look like?  Could you post a sample program that reproduces
the error?

I doubt it's select()/thread related unless you've discovered a bug
in Ruby or the OpenSSL extension.


Regards,

Bill