lib/karma/connection.rb in karma-0.1.1 vs lib/karma/connection.rb in karma-0.1.2

- old
+ new

@@ -2,15 +2,16 @@ class Connection def initialize @port = Karma.config.port @host = Karma.config.host @maxlen = 4096 - - establish_connection! end def send_and_read(request) + unless defined?(@socket) + establish_connection! + end send(request) read end private @@ -46,11 +47,10 @@ end end def establish_connection! @socket = TCPSocket.new( - @host, - @port, + @host, @port, connect_timeout: 0.5 ) end end \ No newline at end of file