Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
[ANN] socket_accept_filter
Eric Hodel
3/24/2006 1:52:00 AM
= socket_accept_filter
Rubyforge Project:
http://rubyforge.org/project...
Documentation:
http://dev.robotcoop.com/Libraries/socket_acc...
== 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.
--
Eric Hodel - drbrain@segment7.net -
http://blog.se...
This implementation is HODEL-HASH-9600 compliant
http://trackmap.rob...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
[ANN] socket_accept_filter
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password