root/branches/bayshore/eventmachine/README

Revision 34, 3.0 kB (checked in by garbagecat, 3 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 $Id$
2
3 Preliminary README for RUBY/EventMachine
4
5 Author: blackhedd (gmail address: garbagecat20)
6 Date: 8 Apr 2006
7
8 EventMachine implements a fast, single-threaded engine for arbitrary network
9 communications. It's extremely easy to use in Ruby. EventMachine wraps all
10 interactions with IP sockets, allowing programs to concentrate on the
11 implementation of network protocols. It can be used to create both network
12 servers and clients. To create a server or client, a Ruby program only needs
13 to specify the IP address and port, and provide a Module that implements the
14 communications protocol. Implementations of several standard network protocols
15 are provided with the package, primarily to serve as examples. The real goal
16 of EventMachine is to enable programs to easily interface with other programs
17 using TCP/IP, especially if custom protocols are required.
18
19 A Ruby program uses EventMachine by registering the addresses and ports of
20 network servers and clients, and then entering an event-handling loop.
21 EventMachine contains glue code in Ruby which will execute callbacks to
22 user-supplied code for all significant events occurring in the clients
23 and servers. These events include connection acceptance, startup, data-receipt,
24 shutdown, and timer events. Arbitrary processing can be performed by user code
25 during event callbacks, including sending data to one or more remote network
26 peers, startup and shutdown of network connections, and installation of new
27 event handlers.
28
29 The EventMachine implements a very familiar model for network programming.
30 It emphasizes: 1) the maximum possible isolation of user code from network
31 objects like sockets; 2) maximum performance and scalability; and 3) extreme
32 ease-of-use for user code. It attempts to provide a higher-level interface
33 than similar projects which expose a variety of low-level event-handling
34 and networking objects to Ruby programs.
35
36 The design and implementation of EventMachine grows out of nearly ten years
37 of experience writing high-performance, high-scaling network server applications.
38 We have taken particular account of the challenges and lessons described as
39 the "C10K problem" by Dan Kegel and others.
40
41 EventMachine consists of an extension library written in C++ (which can be
42 accessed from languages other than Ruby), and a Ruby module which can be dropped
43 into user programs. The current implementation uses the select(2) system call
44 and may be used on a range of Unix-like systems. A future version of EventMachine
45 for Linux will use epoll(4) and will thus require a Linux 2.6 kernel.
46 Here's a fully-functional echo server written with EventMachine:
47
48       require 'rubygems'
49       require_gem 'eventmachine'
50
51       module EchoServer
52         def receive_data data
53           send_data ">>>you sent: #{data}"
54           close_connection if data =~ /quit/i
55         end
56       end
57
58       EventMachine::run {
59         EventMachine::start_server "192.168.0.100", 8081, EchoServer
60       }
61
62 EventMachine is licensed under GPL. We will be adding full support for
63 SSL/TLS-encryption based on OpenSSL in the near future.
64
65
Note: See TracBrowser for help on using the browser.