From: Rich Date: 2002-11-01T01:26:46+09:00 Subject: Re: Is this the best start to ruby socket server for flash clients? I thought threading in Ruby was not the fastest way... since it doesn't use native threads... -Rich (aka VAYKENT) ----- Original Message ----- From: "Rick" Newsgroups: comp.lang.ruby To: "ruby-talk ML" Sent: Thursday, October 31, 2002 2:59 AM Subject: Is this the best start to ruby socket server for flash clients? > Hello, > > My goal is to make the fastest, most stable Ruby persistant socket > server for Flash clients as possible. I'd like it to run on a Windows > 2000 server, but if sold on Redhat Linux for this application, then > that's fine. > > How many persistant sockets could this app handle in your experience > as is or with your improvements? Currently it kicks back what gets > sent to it. > > The code below is my foundation, how I can make it even better for to > meet the stated goals. Your ideas are encouraged and appreciated. > > Thank you, > > Rick > > > require "socket" > > listenIp = "0.0.0.0" > listenPort = 1234 > > socket = TCPServer.new(listenIp,listenPort) > socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true) > > begin > while > thisThread = Thread.new(session = socket.accept) {|thisSession| > while thisSession > # assuming a flash client > fromClient = thisSession.gets("\0") > thisSession.write(fromClient) > # is sleep a good idea, and then awaken when needed? > end > } > end > rescue StandardError => bang > print "show error: " + bang > end >