Roger Pack
2007-Oct-30 08:40 UTC
[Eventmachine-talk] Eventmachine-talk Digest, Vol 18, Issue 21
> > > This would work well for my type of scenario because I have one server > on > > one port ''per file'' > > so I can instruct the server (once) which file it''s associated with and > > have that information available for each client as it attaches. > > > I''m not seeing what you need to do that can''t be accomplished by using a > Class for your connection-handler rather than an mixed-in module. For > example: > > class A < EM::Connection > end > > class B < EM::Connection > end > > EM.run { > start_server( addressA, portA, A ) {|conn| ...... } > start_server( addressB, portB, B ) {|conn| ...... } > }Hmm. It would be useful for me because I have the FileServer < EM::Connection end class then arbitrarily, later, I want to start new servers to handle new files, on request. So a ''setup'' phase for each server class instance is to tell it which file it is serving, then, as clients connect, it should process those clients appropriately. Kind of like if it were monitoring a directory, as new files are created in that directory then it will throw up a server (on its own port) with that file, and each connection to that port would serve that file. Similar. I suppose it''s not too efficient to do it that way, in retrospect (multiplexing on the incoming connection would be nicer), but it''s nice for load testing and things, and keeps things cleanly separated for serving.> Now...a few questions about EM I still have are: > > Francis said > > " EM has its own internal buffers for each inbound connection. " > > So I am to understand that if one socket''s data incoming data is > processed > > and control returns to EM, it will buffer all the incoming data for each > > open socket, then process the next socket''s buffered data? Just double > > checking that things run sensibly :) > > > The EM reactor loops around to each connected socket. For each one that > has > data available to read, "some or all" of the data are read out and passed > to > user-written event handlers. The reactor blocks until the user code > returns, > at which point it dispatches data from the next readable socket in the > sequence.So there aren''t "extra" internal read buffers per socket, is that right? Only the kernel level ones (which, as you pointed out, are still filling as other code is processing).> > that generate a lot of output, but unfortunately is underdocumented.Thank you! -Roger -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071030/2a19b45a/attachment.html
Francis Cianfrocca
2007-Oct-30 10:57 UTC
[Eventmachine-talk] Eventmachine-talk Digest, Vol 18, Issue 21
On 10/30/07, Roger Pack <rogerpack2005 at gmail.com> wrote:> > > Hmm. It would be useful for me because I have the > FileServer < EM::Connection > end > class > > then arbitrarily, later, I want to start new servers to handle new files, > on request. So a ''setup'' phase for each server class instance is to tell it > which file it is serving, then, as clients connect, it should process those > clients appropriately. Kind of like if it were monitoring a directory, as > new files are created in that directory then it will throw up a server (on > its own port) with that file, and each connection to that port would serve > that file. Similar. > > I suppose it''s not too efficient to do it that way, in retrospect > (multiplexing on the incoming connection would be nicer), but it''s nice for > load testing and things, and keeps things cleanly separated for serving. >I''m still not sure I''m getting this. Would you like to start up multiple servers, one for each of the files you want to serve? So you''d allocate a different IP address/port combination for each of these several servers?> Now...a few questions about EM I still have are: > > > Francis said > > > " EM has its own internal buffers for each inbound connection. " > > > So I am to understand that if one socket''s data incoming data is > > processed > > > and control returns to EM, it will buffer all the incoming data for > > each > > > open socket, then process the next socket''s buffered data? Just double > > > checking that things run sensibly :) > > > > > > The EM reactor loops around to each connected socket. For each one that > > has > > data available to read, "some or all" of the data are read out and > > passed to > > user-written event handlers. The reactor blocks until the user code > > returns, > > at which point it dispatches data from the next readable socket in the > > sequence. > > > So there aren''t "extra" internal read buffers per socket, is that right? > Only the kernel level ones (which, as you pointed out, are still filling as > other code is processing). >Correct. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071030/92d6e3df/attachment.html