From: Ben Armstrong Date: 2004-11-13T02:13:27+09:00 Subject: Re: Socket problem On Fri, 05 Nov 2004 19:29:16 +0000, Ben Armstrong wrote: > It has > been alleged that this might be a C Runtime issue. But this seems > unlikely in light of the fact that other ports on the same platform -- > notably Perl, and perhaps also Python -- have working sockets, also > implemented on top of the same C Runtime. I guess the factor we probably didn't consider is that although these languages use the same C Runtime, they may not all use it in the same way, so now my question is, given the following findings, how can our Ruby port be fixed so that it behaves like Perl? What I've found out is that if I follow each 'gets' and 'puts' with 'fsync', the output from my test is as expected on OpenVMS: -- server.rb -- require 'socket' gs = TCPServer.open(0) printf("server is on port %d\n", gs.addr[1]) s=gs.accept line = s.gets s.fsync puts("Got line: #{line}") s.puts(line.upcase) s.fsync bl = s.gets s.fsync puts ("Got str2: #{bl}") s.puts(bl.upcase) s.fsync s.close -- end server.rb -- -- client.rb -- require 'socket' s=TCPSocket.new("localhost", ARGV[0]) s.puts("test\r\n") s.fsync puts s.gets s.fsync s.puts("Blah, blah\r\n") s.fsync puts s.gets s.fsync s.close -- end client.rb -- Ruby's IO module sets the buffer to _IOFBF via setvbuf. I don't see any such construct in the Perl source. Is there a reason Ruby is doing this and Perl isn't? Ben -- Ben Armstrong -. Medianet Development Group, BArmstrong@dymaxion.ca `-. Dymaxion Research Limited `- Halifax, Nova Scotia, Canada