Class: FCGI::FastCGISocket

Inherits:
Object
  • Object
show all
Defined in:
lib/cgialt/fcgi/core.rb

Instance Method Summary collapse

Constructor Details

#initialize(sock) ⇒ FastCGISocket

Returns a new instance of FastCGISocket.



186
187
188
# File 'lib/cgialt/fcgi/core.rb', line 186

def initialize(sock)
  @socket = sock
end

Instance Method Details

#read_recordObject



190
191
192
193
194
195
# File 'lib/cgialt/fcgi/core.rb', line 190

def read_record
  header = @socket.read(Record::HEADER_LENGTH) or return nil
  return nil unless header.size == Record::HEADER_LENGTH
  version, type, reqid, clen, padlen, reserved = *Record.parse_header(header)
  Record.class_for(type).parse(reqid, read_record_body(clen, padlen))
end

#send_record(rec) ⇒ Object



208
209
210
211
# File 'lib/cgialt/fcgi/core.rb', line 208

def send_record(rec)
  @socket.write rec.serialize
  @socket.flush
end