Forum: Ruby socket_accept_filter

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric H. (Guest)
on 2006-03-24 03:52
(Received via mailing list)
= socket_accept_filter

Rubyforge Project:


== About

Socket#set_accept_filter allows you to enable accept filters on
server sockets.

In FreeBSD accept filters allow you to delay the return from an accept
() call
until enough data arrives on the connection for processing avoiding
context switches while waiting for the missing data.

Consult the accf_data(9), accf_http(9) and accept_filter(9) man pages
further details.

== Installing socket_accept_filter

Run FreeBSD (or any BSD, I think).

Then install the gem:

   $ sudo gem install socket_accept_filter

== Using socket_accept_filter

=== Regular sockets

   require 'rubygems'
   require 'socket'
   require 'socket_accept_filter'

   server = host, port
   server.set_accept_filter 'dataready'

Then use the server socket as you would ordinarily.

=== WEBrick

   require 'rubygems'
   require 'socket'
   require 'socket_accept_filter'
   require 'webrick'

   class MyServer < WEBrick::HTTPServer

     def listen(*args)

       @listeners.each do |server|
         server.set_accept_filter 'httpready'


Then use MyServer where you would ordinarily use WEBrick::HTTPServer.

Eric H. - removed_email_address@domain.invalid -
This implementation is HODEL-HASH-9600 compliant
This topic is locked and can not be replied to.