From: Ken Collins Date: 2005-01-12T04:02:21+09:00 Subject: Re: question about YAML over sockets > > As far as I can tell, YAML.load will not return until the sender closes > > the socket. Is this true? If true, is this desirable? > > > If you need to have YAML.load return before you've closed the socket, > send a pause indicator "\n...\n". YAML.load will return and you can > read further documents from the same IO. > > _why I tried sending the pause indicator using a variety of plausible IO methods (write, print, puts, etc.) but without success. The receiver listed below prints the data but only after five seconds. Sender: require "socket" require "yaml" data = { 'a' => [1,2,3], 'b' => 43 } server = TCPServer.new("localhost", 5555) socket = server.accept YAML.dump(data, socket) socket.write "\n...\n" sleep 5 Receiver: require "socket" require "yaml" socket = TCPSocket.new("localhost", 5555) data = YAML.load(socket) p data