[ANN] socket_accept_filter

E

Eric Hodel

= socket_accept_filter

Rubyforge Project:

http://rubyforge.org/projects/rctools/

Documentation:

http://dev.robotcoop.com/Libraries/socket_accept_filter

== 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
extra
context switches while waiting for the missing data.

Consult the accf_data(9), accf_http(9) and accept_filter(9) man pages
for
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 = TCPServer.new 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)
super

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

end

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top