[Win32utils-devel] TCPServer failure within daemon

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Tue Feb 10 13:36:58 EST 2004


I wanted to see if I could setup a simple echo server to run as a
service.  So, using daemon_test.rb, I modified the Daemon class to
something like this:

require "socket"
class Daemon
   def initialize
      @server = TCPServer.new("localhost",8888)
   end

   def service_main
      while state == RUNNING
         while session = @server.accept
            str = session.gets.chomp
            File.open("c:\\foo.log","a+"){ |f| f.puts "Got #{str}" }
         end
      end
   end
end

It starts up ok, but if I try to connect with a client on that port, I
get an error on the client side saying the connection was refused.  In
addition, the service dies unexpectedly and the Event Log says "The
service terminated unexpectedly".

I tried a couple minor variations on the code above, but I always get
the same result.

Any ideas?

Dan



More information about the win32utils-devel mailing list