Jay Phillips
2008-Jan-08 09:52 UTC
[Eventmachine-talk] Handling events over a socket with no delimiter?
Hi guys, Is there a sanctioned way of modifying the socket-level loop (in Ruby) which eventually passes chunks of data to receive_data()? I''m having to parse a protocol that doesn''t always use a delimiter between events: sometimes it''s "\r\n\r\n" and sometimes it wants you to read_nonblock(1) until nothing else exists on the wire (effectively raising EAGAIN), then handle it. Yes, it''d help if you felt sorry for me. ;) Jay Phillips
Roger Pack
2008-Jan-08 10:08 UTC
[Eventmachine-talk] Handling events over a socket with no
so it doesn''t block read after sending "\r\n\r\n"? Maybe hack the c code? :) Take care. On Jan 8, 2008 10:52 AM, Jay Phillips <jicksta at gmail.com> wrote:> Hi guys, > > Is there a sanctioned way of modifying the socket-level loop (in Ruby) > which eventually passes chunks of data to receive_data()? I''m having > to parse a protocol that doesn''t always use a delimiter between > events: sometimes it''s "\r\n\r\n" and sometimes it wants you to > read_nonblock(1) until nothing else exists on the wire (effectively > raising EAGAIN), then handle it. > > Yes, it''d help if you felt sorry for me. ;) > > Jay Phillips > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- -Roger Pack For God hath not given us the spirit of fear; but of power, and of love, and of a sound mind" -- 2 Timothy 1:7
Kirk Haines
2008-Jan-08 10:18 UTC
[Eventmachine-talk] Handling events over a socket with no
On Jan 8, 2008 10:52 AM, Jay Phillips <jicksta at gmail.com> wrote:> Is there a sanctioned way of modifying the socket-level loop (in Ruby) > which eventually passes chunks of data to receive_data()? I''m having > to parse a protocol that doesn''t always use a delimiter between > events: sometimes it''s "\r\n\r\n" and sometimes it wants you to > read_nonblock(1) until nothing else exists on the wire (effectively > raising EAGAIN), then handle it. > > Yes, it''d help if you felt sorry for me. ;)How do you know when using this protocol if you look for \r\n\r\n or if you keep reading? How do you know that there really is no more data, and that isn''t just a delay caused by something out on the network? Kirk Haines
Bill Kelly
2008-Jan-08 10:42 UTC
[Eventmachine-talk] Handling events over a socket with no
From: "Jay Phillips" <jicksta at gmail.com>> > Is there a sanctioned way of modifying the socket-level loop (in Ruby) > which eventually passes chunks of data to receive_data()? I''m having > to parse a protocol that doesn''t always use a delimiter between > events: sometimes it''s "\r\n\r\n" and sometimes it wants you to > read_nonblock(1) until nothing else exists on the wire (effectively > raising EAGAIN), then handle it.It''s not OpenNap, is it? :( What you''re describing sounds similar to the absolute horror I recall seeing in that protocol, where they believe that if they send data over TCP, that when the remote end select''s true for read, all the data will have arrived in one "packet". I read about that years ago, and I still go into fits of nausea every time I think about it. But... if what you''re asking about is like that, what is the snag with the EventMachine semantics? Doesn''t receive_data get called as soon as the reactor gets data from the Kernel? And doesn''t receive_data pass along all that data that was available at that point? I''m not understanding the problem, I guess... Regards, Bill
Tony Arcieri
2008-Jan-08 10:46 UTC
[Eventmachine-talk] Handling events over a socket with no
LineAndTextProtocol is designed to do that sort of thing... it lets you flip it out of line mode into binary mode There''s also LineAndText2 but I don''t really understand what it does differently. On Jan 8, 2008 10:52 AM, Jay Phillips <jicksta at gmail.com> wrote:> Hi guys, > > Is there a sanctioned way of modifying the socket-level loop (in Ruby) > which eventually passes chunks of data to receive_data()? I''m having > to parse a protocol that doesn''t always use a delimiter between > events: sometimes it''s "\r\n\r\n" and sometimes it wants you to > read_nonblock(1) until nothing else exists on the wire (effectively > raising EAGAIN), then handle it. > > Yes, it''d help if you felt sorry for me. ;) > > Jay Phillips > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20080108/296e2f1e/attachment.html
Roger Pack
2008-Jan-08 10:48 UTC
[Eventmachine-talk] Handling events over a socket with no
> But... if what you''re asking about is like that, what is the > snag with the EventMachine semantics? Doesn''t receive_data get > called as soon as the reactor gets data from the Kernel? And > doesn''t receive_data pass along all that data that was available > at that point?receive_data receives ''up to but not necessary all of kernel data'' -- at least on mac os x it tends to receive the size of the receive buffer, I think, so no conflict, but if there is somehow a lot of input, it will read some of it call receive_data, then reloop and call receive_data again. That part of the code you might be able to tweak, but it might be nontrivial.
Tony Arcieri
2008-Jan-08 10:50 UTC
[Eventmachine-talk] Handling events over a socket with no
Whoops missed the bit about a nonblocking read at the end... what the crap protocol? Sounds like it should be using UDP or something... On Jan 8, 2008 11:46 AM, Tony Arcieri <tony at clickcaster.com> wrote:> LineAndTextProtocol is designed to do that sort of thing... it lets you > flip it out of line mode into binary mode > > There''s also LineAndText2 but I don''t really understand what it does > differently. > > > On Jan 8, 2008 10:52 AM, Jay Phillips <jicksta at gmail.com> wrote: > > > Hi guys, > > > > Is there a sanctioned way of modifying the socket-level loop (in Ruby) > > which eventually passes chunks of data to receive_data()? I''m having > > to parse a protocol that doesn''t always use a delimiter between > > events: sometimes it''s "\r\n\r\n" and sometimes it wants you to > > read_nonblock(1) until nothing else exists on the wire (effectively > > raising EAGAIN), then handle it. > > > > Yes, it''d help if you felt sorry for me. ;) > > > > Jay Phillips > > _______________________________________________ > > Eventmachine-talk mailing list > > Eventmachine-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/eventmachine-talk > > > > > > -- > Tony Arcieri > ClickCaster, Inc. > tony at clickcaster.com-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20080108/9ad3d98d/attachment-0001.html