From: "Ara.T.Howard" Date: 2005-10-02T08:51:15+09:00 Subject: Re: Sending YAML over TCP On Sun, 2 Oct 2005, lists wrote: > Hi, > I'm trying to send simple data structures (hashes) to a daemon process > one one machine from a client process via TCP. I thought the best way to do > this would be with XML or YAML. Here's my simple server: > > --- > require 'socket' > > server = TCPServer.new('127.0.0.1', 8080) > > while (session = server.accept) > session.puts session.gets > session.close > end > --- > > Here's my simple client: > > --- > require 'socket' > require 'yaml' > require 'base64' > > hash = { 'one'=>'1', 'two'=>'2'} # Send this to the server and get it back > > client = TCPSocket.new('127.0.0.1', 8080) > client.puts Base64.encode64(h.to_yaml) > hash = YAML.load( Base64.decode64(client.gets) ) > client.close > p hash > --- > > Obviously I don't know what I'm doing :-) The above client/server works for > my simple purposes, but I wanted to know if there's a better way to pass > hashes from the client to the server and back. I'd prefer to stick with YAML > (rather than XML) if possible. > > Thanks, > Ryan why not drb - then you can pass any object and needed bother with yaml/xml, etc. ?? -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================