CARVIEW |
Every repository with this icon (

Every repository with this icon (

Description: | Non-blocking I/O support for Ruby OpenSSL |
Homepage: | https://rev.rubyforge.org/ |
Clone URL: |
git://github.com/tarcieri/openssl-nonblock.git
Give this clone URL to anyone.
git clone git://github.com/tarcieri/openssl-nonblock.git
|

name | age | message | |
---|---|---|---|
![]() |
.gitignore | Fri Feb 06 22:05:00 -0800 2009 | .gitignore for pkg [Tony Arcieri] |
![]() |
CHANGES | Mon Mar 09 22:55:55 -0700 2009 | Bump version number and CHANGES [Tony Arcieri] |
![]() |
LICENSE | Loading commit data... ![]() |
|
![]() |
README.textile | ||
![]() |
Rakefile | Fri Feb 06 14:11:41 -0800 2009 | Import initial C extension code over from Rev [Tony Arcieri] |
![]() |
ext/ | ||
![]() |
lib/ | ||
![]() |
openssl-nonblock.gemspec | ||
![]() |
tasks/ |
openssl-nonblock
Ruby recently added a bunch of non-blocking operations to its core socket classes, like connect_nonblock, read_nonblock, etc. There are plans to add similar methods to the SSL library of future versions of Ruby. However, there’s no reason you can’t have these methods today.
With a bit of crazy C hackery, this module will patch existing versions of Ruby, including 1.8.6, 1.8.7, and 1.9.1 to include non-blocking SSL support.
Installation
openssl-nonblock is installable as a gem. Just run:
gem install openssl-nonblock
to install it.
Alternatively, you may build it from the git repo. Run:
rake gem
to build a gem in the package directory, then:
gem install pkg/openssl-nonblock-X.Y.Z.gem
to install it.
Usage
Once the openssl-nonblock gem has been installed, use:
require 'openssl/nonblock'
to include non-blocking SSL support in your program. This will also pull in the ‘openssl’ library if you haven’t required it already.
Additional methods
The openssl-nonblock gem adds four new methods to the OpenSSL::SSL::SSLSocket class. These methods are:
- connect_nonblock: connect to an SSL server
- accept_nonblock: accept an SSL connection
- read_nonblock(length): read up to the given length, but don’t block
- write_nonblock(data): write as much of the given data as possible without blocking
Exceptions
The openssl-nonblock adds two new exception objects which are needed for correct I/O behavior when using this module. Any of the *_nonblock versions of the SSL methods added by this module will require proper handling of these exceptions:
- OpenSSL::SSL::ReadAgain: this means OpenSSL needs to read more data to complete the given request. You should wait until the underlying IO object becomes readable again before retrying the request.
- OpenSSL::SSL::WriteAgain: similar to above, except OpenSSL is trying to write data to the IO object, and the IO object is not presently writable. You should wait until the object becomes writable again before retrying the request.
Possible compatibility problems
ruby-core is officially trying to add nonblocking SSL support, however at the present time it is insufficient for full non-blocking SSL support. Please be aware that this extension may conflict with future versions of Ruby.
Problems?
openssl-nonblock is a subcomponent of Rev, an event library for Ruby. Please address any questions about openssl-ruby to the rev-talk mailing list at:
https://rubyforge.org/mailman/listinfo/rev-talk
Additional information about Rev is available at: