On Mon, Nov 28, 2011 at 6:55 PM, mohit b. <mohitbansal111 / gmail.com> 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 =3D true
> dts =3D TCPServer.new('localhost', 20000)
> begin
> loop do
> =A0puts" Inside the Loop to accept Client Request #{dts}"
> =A0Thread.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.

> =A0print(s, " is accepted\n")
> =A0 =A0print(s, " is accepted\n")
> =A0 =A0 =A0 =A0s.write(Time.now)
> =A0 =A0 =A0 =A0print(s, " is gone\n")
> =A0 =A0 =A0 =A0s.close
> =A0end
>
> end
> end
>
> Output while running this on WindowsXP Operating system
>
> C:\Documents and Settings\verma.r\My Documents\RubyTest>ruby server.rb
> =A0Inside the Loop to accept Client Request #<TCPServer:0x11cf8c8>
> 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 mess=
ages?

> 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


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/