event-driven networking

Discussion in 'Ruby' started by Lenny G., Jan 20, 2006.

  1. Lenny G.

    Lenny G. Guest

    Is there an event-driven network programming framework available in
    Ruby? I'm looking for something like libasync (c/c++) or twistedmatrix
    (python) that lets me respond to network or file-descriptor events in a
    single-threaded (well, two-threaded if you count the event loop),
    event-driven, callback sort of way.

    I've been googling to try to find such a beast, but can't seem to
    turn anything up. I'm new to ruby so it may be that its just so
    natural to do event-driven network code in ruby that no one talks much
    about it. After having experienced both libasync and twisted, there is
    no other way I'd ever code up a protocol. Does something like this
    exist, or has someone started creating something like it?

    Thanks,
    Lenny
     
    Lenny G., Jan 20, 2006
    #1
    1. Advertising

  2. Lenny G.

    Lenny G. Guest

    Lawrence Oluyede wrote:
    >
    > There was a similar thread a while ago, search for it in Google groups.
    > The response was "practically no". So if you are new to ruby and you know
    > twisted, why don't using it?


    Okay, I think I see the thread.

    So the reason this is important is that I'd like to do some Rails
    work where the backend Ruby code implements a custom network protocol,
    and I'd like for that to happen in an event-driven way.

    Right now, the Python Rails equivalents don't really seem to be up to
    snuff, so If I chose to do the whole thing in Python, I'd give up the
    advantages of Rails.

    Right now, the Ruby event-driven networking stuff doesn't seem to
    exist, so if I choose to do the whole thing in Ruby, I'd give up the
    advantages of that.

    Do you know if anyone is writing an event-driven networking framework
    for Ruby? That certainly seems like something that could be very
    useful.

    Lenny
     
    Lenny G., Jan 20, 2006
    #2
    1. Advertising

  3. Lenny G.

    X-Man Guest

    Couldn't you use DRuby (require 'drb')? That's what I do in my Rails
    program. In the 2nd (distributed) server, I spawn a thread immediately
    upon request to the the work, and then return right away to the web
    process, which returns immediately to the browser.

    I don't have callbacks, but I imagine it would be dead-easy to have the
    2nd server take a request ID from the 1st, then just call back using a
    DRuby call just like the 1st, pushing back the original request ID.

    This is the "asynchronous completion token pattern" as described by
    Schmidt. Here's the (very verbose) write-up ...
    http://www.cs.wustl.edu/~schmidt/PDF/ACT.pdf
     
    X-Man, Jan 21, 2006
    #3
  4. Lenny G.

    Gene Tani Guest

    Lawrence Oluyede wrote:
    > AFAIK there's no Twisted (or nothing like that) in Ruby (one of the reason why
    > I'll not ever make the switch from Python)


    but this must be a very entertaining or informative list, or something
    in ruby caught your eye...
     
    Gene Tani, Jan 22, 2006
    #4
  5. Lenny G.

    Guest

    On Jan 24, 2006, at 9:38 AM, wrote:

    > You certainly could use the asynchronous completion token pattern, but
    > I think if you compared implmenting that vs. implementing it using an
    > event-driven framework -- even using Schmidt's EMIS Management system
    > example, you'd see that the event-driven framework is not only a lot
    > less work, much less error-prone and easier to debug, but also
    > higher-performance (of the three advantages, I actually consider the
    > performance to be least important).
    >
    > I know that this type of proclamation sounds like pie-in-the-sky
    > bigotry against well-established practices, but I'm not kidding: once
    > you go event-driven, you never go back.
    >
    > If there is someone already working on a libasync equivalent in Ruby,
    > I'd love to pitch in. If not, I'd love to think that I could start
    > one
    > up.
    >
    > Python's twisted is very nice, but they've implemented way up the
    > stack. I'd settle for something as dead simple as a generic
    > event-driven TCP/UDP programming framework.


    You might want to take a look at the Myriad framework [1] written by
    Zed Shaw. I'm not so sure it is fully functional because I believe it
    depends upon his Ruby/Event framework that he abandoned. Perhaps
    you'd want to continue his work.

    [1] http://zedshaw.com/projects/myriad/index.html
     
    , Jan 24, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peri
    Replies:
    6
    Views:
    8,080
  2. F
    Replies:
    1
    Views:
    425
  3. christopher diggins
    Replies:
    4
    Views:
    420
    christopher diggins
    Dec 21, 2004
  4. jose luis fernandez diaz

    Using signals as a event driven framework

    jose luis fernandez diaz, May 3, 2004, in forum: C Programming
    Replies:
    6
    Views:
    425
    Xenos
    May 3, 2004
  5. Ben Kial
    Replies:
    0
    Views:
    390
    Ben Kial
    Oct 12, 2003
Loading...

Share This Page