Class: Puma::MiniSSL::Socket
- Inherits:
-
Object
- Object
- Puma::MiniSSL::Socket
- Defined in:
- lib/puma/minissl.rb
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(socket, engine) ⇒ Socket
constructor
A new instance of Socket.
- #peeraddr ⇒ Object
- #read_nonblock(size) ⇒ Object
- #readpartial(size) ⇒ Object
- #to_io ⇒ Object
- #write(data) ⇒ Object (also: #syswrite)
Constructor Details
#initialize(socket, engine) ⇒ Socket
Returns a new instance of Socket.
4 5 6 7 |
# File 'lib/puma/minissl.rb', line 4 def initialize(socket, engine) @socket = socket @engine = engine end |
Instance Method Details
#close ⇒ Object
74 75 76 |
# File 'lib/puma/minissl.rb', line 74 def close @socket.close end |
#flush ⇒ Object
70 71 72 |
# File 'lib/puma/minissl.rb', line 70 def flush @socket.flush end |
#peeraddr ⇒ Object
78 79 80 |
# File 'lib/puma/minissl.rb', line 78 def peeraddr @socket.peeraddr end |
#read_nonblock(size) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puma/minissl.rb', line 30 def read_nonblock(size) while true output = @engine.read return output if output data = @socket.read_nonblock(size) @engine.inject(data) output = @engine.read return output if output while neg_data = @engine.extract @socket.write neg_data end end end |
#readpartial(size) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/puma/minissl.rb', line 13 def readpartial(size) while true output = @engine.read return output if output data = @socket.readpartial(size) @engine.inject(data) output = @engine.read return output if output while neg_data = @engine.extract @socket.write neg_data end end end |
#to_io ⇒ Object
9 10 11 |
# File 'lib/puma/minissl.rb', line 9 def to_io @socket end |
#write(data) ⇒ Object Also known as: syswrite
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/puma/minissl.rb', line 48 def write(data) need = data.bytesize while true wrote = @engine.write data enc = @engine.extract while enc @socket.write enc enc = @engine.extract end need -= wrote return data.bytesize if need == 0 data = data[need..-1] end end |