From: lists Date: 2005-10-02T08:23:21+09:00 Subject: Sending YAML over TCP 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