[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] ruby-sendfile 0.9.1

Toby DiPasquale

3/26/2006 5:00:00 PM

As promised, I've updated ruby-sendfile to make it more "1.0". There is
a source tarball and gem up on Rubyforge, whichever you prefer. I've
also added unit tests to make sure that full and partial sends work on
both blocking and non-blocking sockets on all supported OSs (everything
that has a recognizable sendfile(2)). Unlike socket_sendfile,
ruby-sendfile can send a partial file with the optional offset and byte
count parameters (see below).

All tests pass on Linux (tested on x86 and AMD64, both 2.6.x) and
FreeBSD (tested on 5.3-RELEASE), and ruby-sendfile will truly be 1.0
when the tests pass on Solaris. They should pass right now, but I don't
have a box to test them on.

P.S. Eric: now _these_ are tests ;-)

[Changelog]

- Improved interface with non-blocking sockets
- Added unit tests for blocking sends
- Added unit tests for nonblocking sends
- Added README
- Packaged in a RubyGem

[README]

= Ruby sendfile(2) Interface

This module allows Ruby programs to access their OS's native
sendfile(2) system call from any IO object. Your kernel must
export a recognized signature for the sendfile(2) system call
to use this module. Currently, that includes Linux, Solaris
and FreeBSD.

== Installation

Download and install the latest package from the rubyforge.org
RubyGems repository.

gem install sendfile --remote
gem check sendfile --test

If the tests all pass, you're ready to start using sendfile.

Or, if you don't have rubygems installed, you can install by
hand by downloading the tarball:

tar xzvf ruby-sendfile-<latest>.tar.gz
cd ruby-sendfile-<latest>/ext
ruby extconf.rb
make
sudo make install

== Usage

Here's a small example of a use of IO#sendfile.

require 'socket'
require 'rubygems'
require 'sendfile'

s = TCPSocket.new 'yourdomain.com', 5000
File.open 'somefile.txt' { |f| s.sendfile f }
s.close

See the test scripts for more examples on how to use this
module.

== Contact Information

This project's homepage is:

http://rubyforge.org/projects/rub...

Thereupon are forums for discussing issues
can be found for working out any issues you may have with this
module. In the last case, you can email questions or patches
to toby@cbcg.net.

--
Toby DiPasquale

--
Posted via http://www.ruby-....


2 Answers

Ara.T.Howard

3/26/2006 5:06:00 PM

0

Zed A. Shaw

3/27/2006 4:26:00 AM

0

Toby,

You are calling a "rv_sys_fail" function in sendfile.c instead of
rb_sys_fail. Otherwise seems to work great. I'll be adding this as a
dynamic require for Mongrel so if folks have it installed it will be used in
the DirHandler.

Zed A. Shaw
http://www.ze...


On 3/26/06 11:59 AM, "Toby DiPasquale" <toby@cbcg.net> wrote:

> == Usage
>
> Here's a small example of a use of IO#sendfile.
>
> require 'socket'
> require 'rubygems'
> require 'sendfile'
>
> s = TCPSocket.new 'yourdomain.com', 5000
> File.open 'somefile.txt' { |f| s.sendfile f }
> s.close
>
> See the test scripts for more examples on how to use this
> module.
>