From: ara.t.howard@... Date: 2006-03-24T12:24:01+09:00 Subject: Re: [ANN] socket_sendfile On Fri, 24 Mar 2006, Eric Hodel wrote: > = socket_sendfile > > Rubyforge Project: > > http://rubyforge.org/projects/rctools/ > > Documentation: > > http://dev.robotcoop.com/Libraries/socket_sendfile/ > > == About > > Socket#sendfile implements sendfile(2) for sending files without copying data > to the process. See the sendfile(2) manual page for more details. > > Note that your system must support the sendfile(2) system call the same way > FreeBSD does for Socket#sendfile to work. > > == Installing socket_sendfile > > First you need an OS that supports sendfile() the way FreeBSD does. > > Then install the gem: > > $ sudo gem install socket_sendfile > > == Using socket_sendfile > > require 'rubygems' > require 'socket' > require 'socket_sendfile' > > socket = TCPSocket.open host, port > > File.open 'myfile' do |fp| > socket.sendfile fp > end i'm just about to write a server which sends 1-3gb images as the response... this could be quite useful. one gripe. it doesn't work: /home/ahoward is insecure (40777), needs 0700 for perms. Exiting i work in a collaborative lab... all our home dirs are group readable by default. any way to adjust this? an env var perhaps? seems like this should just warn. ok. one more issue: fortytwo :~/tmp > ruby ../a.rb /usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/RubyInline-3.4.0/./inline.rb:392: warning: Insecure world writable dir /usr/local, mode 040777 /usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/socket_sendfile-1.1.0/lib/socket_sendfile.rb: In function `bsock_sendfile': /usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/socket_sendfile-1.1.0/lib/socket_sendfile.rb:46: warning: implicit declaration of function `sendfil e' /usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/RubyInline-3.4.0/./inline.rb:396:in `build': error executing gcc -shared -Wall -W -Wpointer-arith - Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-noreturn -Werror -g -O2 -I /usr/local/ruby-1.8.4/lib/ruby/1.8/i686-linux -o /home/ahoward/.rub y_inline/Inline_BasicSocket_0a2b.so /home/ahoward/.ruby_inline/Inline_BasicSocket_0a2b.c : 256 (CompilationError) Renamed /home/ahoward/.ruby_inline/Inline_BasicSocket_0a2b.c to /home/ahoward/.ruby_inline/Inline_BasicSocket_0a2b.c.bad from /usr/local/ ruby-1.8.4/lib/ruby/gems/1.8/gems/RubyInline-3.4.0/./inline.rb:591:in `inline' from /usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/socket_sendfile-1.1.0/lib/socket_sendfile.rb:6 from /usr/local/ruby-1.8.4/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ../a.rb:3 my system definitely has sendfile fortytwo :~/tmp > PAGER=cat man sendfile|head -12 SENDFILE(2) Linux Programmer's Manual SENDFILE(2) NAME sendfile - transfer data between file descriptors SYNOPSIS #include ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); guess the signature won't cut it though eh? maybe i'll just have to use dl? regards. -a -- share your knowledge. it's a way to achieve immortality. - h.h. the 14th dali lama