dRuby client/server mode sample program

By: Emiley J. Emailed: 1644 times Printed: 2113 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

This illustrates setting up a simple client-server drb system. Run the server and client code in different terminals, starting the server code first.

Server code

  require 'drb/drb'

  # The URI for the server to connect to
  URI="druby://localhost:8787"

  class TimeServer

    def get_current_time
      return Time.now
    end

  end

  # The object that handles requests on the server
  FRONT_OBJECT=TimeServer.new

  $SAFE = 1   # disable eval() and friends

  DRb.start_service(URI, FRONT_OBJECT)
  # Wait for the drb server thread to finish before exiting.
  DRb.thread.join

Client code

  require 'drb/drb'

  # The URI to connect to
  SERVER_URI="druby://localhost:8787"

  # Start a local DRbServer to handle callbacks.
  #
  # Not necessary for this small example, but will be required
  # as soon as we pass a non-marshallable object as an argument
  # to a dRuby call.
  DRb.start_service

  timeserver = DRbObject.new_with_uri(SERVER_URI)
  puts timeserver.get_current_time

Ruby Home | All Ruby Tutorials | Latest Ruby Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Emiley J.
Error generating R.java from manifest
ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client
IIS and Tomcat - how to configure to work together
PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/php4/lib/php/extensions/no-debug ......
Adding your own Application icon for your J2ME application (jar file)
Creating Menus in Code using VB.net
Traversing all files in a directory using Ruby
Using Proxy to connect to URLs in Ruby
POST a form in Ruby
Reading URL content using Ruby (HTTP)
dRuby client/server mode sample program
Benchmark module in Ruby
encoding and decoding in Ruby using Base64 Module
Module Abbrev in Ruby
Standard Library Packages in Ruby

More Tutorials in Ruby
Standard Library Packages in Ruby
Module Abbrev in Ruby
encoding and decoding in Ruby using Base64 Module
Benchmark module in Ruby
benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
bmbm(width = 0) {|job| ...} in Ruby
CGI class in Ruby
URL encode a string in Ruby
escapeElement() in Ruby
escapeHTML() in Ruby
new(type = "query") in Ruby
parse(query) in Ruby
pretty() in Ruby
Format a Time object as a String in Ruby

More Latest News
Most Viewed Articles (in Ruby )
POST a form in Ruby
encoding and decoding in Ruby using Base64 Module
URL decode a string in Ruby
dRuby client/server mode sample program
Open and manipulate CSV files in Ruby
Action Pack - Ruby On rails from request to response
Prompts, Command Lines, Prompts, and irb in Ruby on rails
The Question Mark Operator in Ruby on rails
Benchmark module in Ruby
escapeHTML() in Ruby
header() in Ruby
date and time in Ruby
What is dRuby?
FTP using Ruby
Using Proxy to connect to URLs in Ruby
Most Emailed Articles (in Ruby)
if . . . elsif . . . else in Ruby on rails
encoding and decoding in Ruby using Base64 Module
Getting started with Ruby on rails
Standard Library Packages in Ruby
Module Abbrev in Ruby
Command-line Arguments in Ruby on rails
unescapeHTML() in Ruby
header() in Ruby
Open and manipulate CSV files in Ruby
Security in dRuby
Reading emails using POP3 in Ruby
Using GServer in Ruby
Using Generator in Ruby
Naming conventions in Ruby on rails
Benchmark module in Ruby