From: ian@... Date: 2008-01-04T19:00:01+09:00 Subject: problem with sockets Hi I've just started using ruby and thought I'd do some experimenting with TCPSocket and TCPServer I've got a small problem, in that the program I've written runs fine on Linux, but runs with a lag on windows. By this I mean that when you type into the client on std input in Linux, what you type is automatically displayed. However in windows nothing happens until you type and send something else. Like it's caught in a buffer and needs to be flushed. I've tried flushing the output stream as you would in Java, but nothing seems to work If anyone could give me some advice I would be eternally grateful. I've searched around the net, but to no avail. Client require 'socket' require 'thread' class Client def initialize host = 'localhost' port = 40000 s = TCPSocket.new(host, 40000) t = Thread.new do while(true) line = s.gets if(line == nil) puts("Program is exiting") break end #of if $stdout.flush puts "Received: #{line}" $stdout.flush end #of while s.close end #of thread while(true) puts("About to run stdin") line = $stdin.gets s.puts(line) end #of while puts 'QUIT' t.join s.close Process.exit end #of con end #of class st = Client.new Server require 'socket' require 'thread' class ServerThread def initialize t = TCPServer.new('localhost', 40000) while(true) go = t.accept s = Thread.new(go) do |v| while(true) # data = "none" data = v.gets v.write(data) if(data == nil) puts("From inside if") self.closeSocket(v) end #of if end # while end #of thread end #end of while s.join end #of constructor def closeSocket(sock) puts("This is closeSocket") sock.close end #of method end #of class s = ServerThread.new Thanks Ian