On Mon, Mar 10, 2003 at 11:43:16AM +0900, Ray Capozzi wrote:
> Thanks for the suggestion.  It looks promising.  I'd like to be able to
> telnet to the servers port without the need of speaking yaml to the sever
> from the telnet session.  It seems that I'd have to adopt yaml whole-hog on
> the Ruby side.  From the docs, the Yaml methods closes the IO channel upon
> doc read.  I can see two approaches.  First, include a tag at the start of a
> session to determine a protocol.  Alternatively, I could create a specific
> control port process just for telnet.  Perhaps there is another alternative.
> I could modify the Yaml stuff to not close the channel after reading a doc.

IIWY I'd forget telnet and just have a little client program for manually
driving the RPC calls:

require 'readline'
$defserver = ['druby://localhost:9000']
conn = nil

while line = (ARGV.shift || Readline::readline("rpc> ",true))
  args = line.split(/\s+/)
  cmd = args.shift
  begin
    case cmd
    when 'connect'
      args = $defserver if args == []
      require 'drb'
      conn = DRbObject.new(nil, *args)   # replace for SOAP, XML-RPC etc
    when 'quit'
      break
    else
      p conn.send(cmd, *args)
    end
  rescue Exception
    puts "Error: #{$!}"
  end
end

Unlike telnet, this also gives you the ability to hit up-arrow and edit your
typing :-) A more sophisticated parser than space-separated would be good,
but otherwise something like the above is working very well for me.

Incidentally, DRb over TCP keeps the connection up for multiple calls. SOAP
and YAML/OKAY should be able to do so as well (using persistent HTTP/1.1
connections) but you may have to tweak either client or server side to
achieve this.

Cheers,

Brian.