box-o-sand/ruby-sockets/marco-polo/client.rb
Dan Buch d67d1632a8 Throwing three non-pausing clients at mysql-backed EM server
is causing intermittent port binding problems which
manifest as an unreachable server.  Inserting a pause
on the client side fixes the problem.  Hm.
2012-06-16 01:07:53 -04:00

26 lines
496 B
Ruby

require 'socket'
successes = 0
backoff = 0.5
loop do
begin
TCPSocket.open('127.0.0.1', 22000) do |sock|
sock.send("sally #{rand(101)} #{rand(101)}\n", 0)
sock.recv(100)
sock.close
STDOUT.write('.')
STDOUT.flush
end
successes += 1
backoff = 0.5
sleep 0.01
rescue
STDOUT.write('E')
STDOUT.flush
STDERR.write("\nmade it #{successes} times. sleeping #{backoff} secs\n")
successes = 0
sleep backoff
backoff *= 2
end
end