Advertisement
paperline27

server&client.rb

Jan 21st, 2024 (edited)
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.37 KB | Cybersecurity | 0 0
  1. #server
  2. require 'drb'
  3.  
  4. class Calculator
  5.   def add(a, b)
  6.     a + b
  7.   end
  8. end
  9.  
  10. calculator = Calculator.new
  11. DRb.start_service('druby://localhost:12345', calculator)
  12. DRb.thread.join
  13.  
  14.  
  15. #client
  16. require 'drb'
  17.  
  18. DRb.start_service
  19. calculator = DRbObject.new_with_uri('druby://localhost:12345')
  20.  
  21. result = calculator.add(5, 3)
  22. puts "Result of remote addition: #{result}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement