win32utils-devel@rubyforge.org
2004-Feb-10 15:41 UTC
[Win32utils-devel] TCPServer failure within daemon
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