v1_9_3_392 -
Show latest stable
-
0 notes
- Superclass:
BasicServer
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (-38)
- 2_2_9 (0)
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
XMLRPC::Server
Synopsis
require "xmlrpc/server" s = XMLRPC::Server.new(8080) s.add_handler("michael.add") do |a,b| a + b end s.add_handler("michael.div") do |a,b| if b == 0 raise XMLRPC::FaultException.new(1, "division by zero") else a / b end end s.set_default_handler do |name, *args| raise XMLRPC::FaultException.new(-99, "Method #{name} missing" + " or wrong number of parameters!") end s.serve
Description
Implements a standalone XML-RPC server. The method (({serve}))) is left if a SIGHUP is sent to the program.
Superclass
Class Methods
— XMLRPC::Server.new( port=8080, host=“127.0.0.1”, maxConnections=4, stdlog=$stdout, audit=true, debug=true, *a )
Creates a new (({XMLRPC::Server})) instance, which is a XML-RPC server listening on port ((|port|)) and accepts requests for the host ((|host|)), which is by default only the localhost. The server is not started, to start it you have to call ((<serve|XMLRPC::Server#serve>)). Parameters ((|audit|)) and ((|debug|)) are obsolete! All additionally given parameters in ((|*a|)) are by-passed to ((<XMLRPC::BasicServer.new>)).
Instance Methods
Call this after you have added all you handlers to the server. This method starts the server to listen for XML-RPC requests and answer them.
Stops and shuts the server down.
XMLRPC::WEBrickServlet
Synopsis
require "webrick" require "xmlrpc/server" s = XMLRPC::WEBrickServlet.new s.add_handler("michael.add") do |a,b| a + b end s.add_handler("michael.div") do |a,b| if b == 0 raise XMLRPC::FaultException.new(1, "division by zero") else a / b end end s.set_default_handler do |name, *args| raise XMLRPC::FaultException.new(-99, "Method #{name} missing" + " or wrong number of parameters!") end httpserver = WEBrick::HTTPServer.new(:Port => 8080) httpserver.mount("/RPC2", s) trap("HUP") { httpserver.shutdown } # use 1 instead of "HUP" on Windows httpserver.start
Instance Methods
— XMLRPC::WEBrickServlet#set_valid_ip( *ip_addr )
Specifies the valid IP addresses that are allowed to connect to the server. Each IP is either a (({String})) or a (({Regexp})).
— XMLRPC::WEBrickServlet#get_valid_ip
Return the via method ((<set_valid_ip|XMLRPC::Server#set_valid_ip>)) specified valid IP addresses.
Description
Implements a servlet for use with WEBrick, a pure Ruby (HTTP-) server framework.
Superclass
((<XMLRPC::BasicServer>))