How do you break out of a server.accept loop?

This works, but I don't know how to get out of the loop. I'm running this on windows xp.
I tried control-c, but it doesn't work. How can I get out of a loop like this?

require 'socket'

server = TCPServer.new('127.0.0.1', 8080)

while (session = server.accept)
   session.puts session.gets
   session.close
end

thanks,
Ralph

Ralph Smith wrote:

This works, but I don't know how to get out of the loop. I'm running this on windows xp.
I tried control-c, but it doesn't work. How can I get out of a loop like this?

require 'socket'

server = TCPServer.new('127.0.0.1', 8080)

while (session = server.accept)
   session.puts session.gets
   session.close
end

thanks,
Ralph

Put "Thread.new { loop { sleep 0.01 } }" somewhere near the top of your program.

Regards,

Dan

Ralph Smith wrote:

This works, but I don't know how to get out of the loop. I'm running
this on windows xp. I tried control-c, but it doesn't work. How can I
get out of a loop like this?

You can for example write an event handler that throws an exception in the
accepting thread.

require 'socket'

server = TCPServer.new('127.0.0.1', 8080)

while (session = server.accept)
   session.puts session.gets
   session.close
end

Kind regards

    robert

Ralph Smith schrieb:

This works, but I don't know how to get out of the loop. I'm running this on windows xp.
I tried control-c, but it doesn't work. How can I get out of a loop like this?

require 'socket'

server = TCPServer.new('127.0.0.1', 8080)

while (session = server.accept)
   session.puts session.gets
   session.close
end

Try CTRL-BREAK.

Regards,
Pit