From: Robert Klemme Date: 2011-11-29T07:05:43+09:00 Subject: Re: TCPServer' s accept method crashes the ruby program On Mon, Nov 28, 2011 at 6:55 PM, mohit b. wrote: > Operating System: Windows XP > Ruby Version: ruby 1.9.2p290 (2011-07-09) [i386-mingw32] > > Program for TCPServer: > > > require "socket" > Thread.abort_on_exception = true > dts = TCPServer.new('localhost', 20000) > begin > loop do >  puts" Inside the Loop to accept Client Request #{dts}" >  Thread.start(dts.accept_nonblock) do |s| You do not want to accept nonblocking in this way here. The accepting thread can block without problems as it does not have to do anything apart from accepting connections - you have your worker threads for client handling. >  print(s, " is accepted\n") >    print(s, " is accepted\n") >        s.write(Time.now) >        print(s, " is gone\n") >        s.close >  end > > end > end > > Output while running this on WindowsXP Operating system > > C:\Documents and Settings\verma.r\My Documents\RubyTest>ruby server.rb >  Inside the Loop to accept Client Request # > C:\Documents and Settings\verma.r\My Documents\RubyTest>ruby server.rb > > > Problem: > > After printing the first puts" Inside the Loop to accept Client Request > #{dts}". The programs crashed in Thread.start(dts.accept_nonblock) > without even using any client to connect to server. What exactly does "crashes" mean? Core dump? Simple exit? Any error messages? > This program is working on some PC and gives this error on other. > Has anyone experienced the same problem before. What can be region for > the crash please suggest. Different timing may have dramatic effects. I am not yet convinced that it actually crashes. Please provide more details. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/