+ def read_socket
+ begin
+ socket = @server.socket
+ while res = socket.read(8096)
+ break if res.size != 8096
+ end
+ #Timeout or server down
+ rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNREFUSED => e
+ server.close
+ puts "Client (#{server.inspect}) disconnected from server: #{e.inspect}\n" if $debug
+ retry
+ rescue Timeout::Error => e
+ #BTM - Ignore this error so we don't go into an endless loop
+ puts "Client (#{server.inspect}) Timeout\n" if $debug
+ #Server down
+ rescue NoMethodError => e
+ puts "Client (#{server.inspect}) tryin server that is down: #{e.inspect}\n Dying!" if $debug
+ raise Errno::ECONNREFUSED
+ #exit
+ end
+ end
+