class DRb::DRbServer

def main_loop

or a local method call fails.
returning responses, until the client closes the connection
from the client, invoking them on a local object, and
thread to handle it. This thread loops, receiving requests
Accepts a connection from a client, and starts up its own

The main loop performed by a DRbServer's internal thread.
def main_loop
  client0 = @protocol.accept
  return nil if !client0
  Thread.start(client0) do |client|
    @grp.add Thread.current
    Thread.current['DRb'] = { 'client' => client ,
                              'server' => self }
    DRb.mutex.synchronize do
      client_uri = client.uri
      @exported_uri << client_uri unless @exported_uri.include?(client_uri)
    end
    _last_invoke_method = nil
    loop do
      begin
        succ = false
        invoke_method = InvokeMethod.new(self, client)
        succ, result = invoke_method.perform
        error_print(result) if !succ && verbose
        unless DRbConnError === result && result.message == 'connection closed'
          client.send_reply(succ, result)
        end
      rescue Exception => e
        error_print(e) if verbose
      ensure
        _last_invoke_method = invoke_method
        client.close unless succ
        if Thread.current['DRb']['stop_service']
          shutdown
          break
        end
        break unless succ
      end
    end
  end
end