This works better if you give the EM main loop a chance to run and clean up occasionally.
See the (simple-minded) demonstrator below.
Grüße, Carsten
require 'eventmachine-le'
class A < EM::Connection
def post_init
close_connection
puts "closed"
end
end
def run_one(x)
puts x
begin
s = EM.open_datagram_socket "0.0.0.0", 0, A
rescue Exception => e
puts [x,e].join("=>")
exit
end
EM.add_timer(0.01) { run_one(x+1) }
end
EM.run {
run_one(0)
}