Do you like Sinatra? Do you like Node.js? Wish you could write Node.js
apps
in Ruby as easily as you write Sinatra apps? Let’s ask Cool.io how:
Cool.io is a framework for building event-driven applications, namely
scalable network servers and clients, but also provides out-of-the-box
support for filesystem monitoring and inter-thread signaling. Cool.io
also
supports a robust event-driven HTTP/1.1 client suitable for creating web
spiders or other HTTP clients that need to make large numbers of
concurrent
connections.
Cool.io is built on libev, a fast C-based event library which also
provides
the underpinnings for evented I/O in Node.js. It works on Ruby 1.8.7+,
1.9.2+, and Rubinius HEAD.
Cool.io 1.0.0 features a cool new DSL which makes writing evented
network
servers and clients this easy. Here’s an example echo server:
require ‘rubygems’
require ‘cool.io’
ADDR = ‘127.0.0.1’
PORT = 4321
cool.io.server ADDR, PORT do
on_connect do
puts “#{remote_addr}:#{remote_port} connected”
end
on_close do
puts “#{remote_addr}:#{remote_port} disconnected”
end
on_read do |data|
write data
end
end
puts “Echo server listening on #{ADDR}:#{PORT}”
cool.io.run
For more information, see the home page.