On Sat, 30 Oct 2004 14:20:47 +0900, Hernan Silberman
<hernan.silberman / gmail.com> wrote:
> Hello,
> 
> I'm in the early stages of learning Ruby.  I've been playing with std
> library classes to get situated a bit and I can't get this simple
> GServer subclass to run properly.  It's taken straight from the
> GServer class docs.  I'm running ruby 1.8.1 on cygwin/winXP.
> 
> require 'gserver'
> class SimpleServer < GServer
>    def initialize(port=10001,*args)
>       super(port,*args)
>    end
>    def serve(io)
>       io.puts(Time.now.to_i)
>    end
> end
> 
> theS = SimpleServer.new
> theS.audit = true
> theS.start
> 
> When I run it, I get this:
> 
> $ ruby NetTest.rb
> [Fri Oct 29 22:10:28 2004] SimpleServer 127.0.0.1:10001 start
> [Fri Oct 29 22:10:28 2004] SimpleServer 127.0.0.1:10001 stop
> 
> No error, but I'm assuming there was some problem binding to port
> 10001 or otherwise starting the server.  How can I dig a little deeper
> to find the cause of the problem?
> 
> many thanks...
> Hernan
> 
> 

You may want to join to the server thread. Try adding:

  theS.join

to the last part of your code snippet. What is happening is the server
object is being garbage collected because your program is exiting.

Peace,
    Brian Mitchell.