Class: Sanford::Server::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/sanford/server.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
1

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Connection

Returns a new instance of Connection.



38
39
40
41
# File 'lib/sanford/server.rb', line 38

def initialize(socket)
  @connection = Sanford::Protocol::Connection.new(socket)
  @timeout    = (ENV['SANFORD_TIMEOUT'] || DEFAULT_TIMEOUT).to_f
end

Instance Method Details

#read_dataObject



43
44
45
# File 'lib/sanford/server.rb', line 43

def read_data
  @connection.read(@timeout)
end

#write_data(data) ⇒ Object



47
48
49
# File 'lib/sanford/server.rb', line 47

def write_data(data)
  @connection.write data
end