# File lib/pr_eventmachine.rb, line 376 376: def open_loopbreaker 377: # Can't use an IO.pipe because they can't be set nonselectable in Windows. 378: # Pick a random localhost UDP port. 379: #@loopbreak_writer.close if @loopbreak_writer 380: #rd,@loopbreak_writer = IO.pipe 381: @loopbreak_reader = UDPSocket.new 382: @loopbreak_writer = UDPSocket.new 383: bound = false 384: 100.times { 385: @loopbreak_port = rand(10000) + 40000 386: begin 387: @loopbreak_reader.bind "localhost", @loopbreak_port 388: bound = true 389: break 390: rescue 391: end 392: } 393: raise "Unable to bind Loopbreaker" unless bound 394: LoopbreakReader.new(@loopbreak_reader) 395: end