Class: Celluloid::IO::SSLSocket

Inherits:
Stream
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/celluloid/io/ssl_socket.rb

Overview

SSLSocket with Celluloid::IO support

Instance Attribute Summary

Attributes inherited from Stream

#sync

Instance Method Summary collapse

Methods inherited from Stream

#<<, #close, #each, #each_byte, #eof?, #flush, #getc, #gets, #print, #printf, #puts, #read, #readchar, #readline, #readlines, #readpartial, #sysread, #syswrite, #ungetc, #wait_readable, #wait_writable, #write

Constructor Details

#initialize(io, ctx = OpenSSL::SSL::SSLContext.new) ⇒ SSLSocket

Returns a new instance of SSLSocket


12
13
14
15
16
# File 'lib/celluloid/io/ssl_socket.rb', line 12

def initialize(io, ctx = OpenSSL::SSL::SSLContext.new)
  super()
  @context = ctx
  @socket = OpenSSL::SSL::SSLSocket.new(::IO.try_convert(io), @context)
end

Instance Method Details

#acceptObject


26
27
28
29
30
31
32
33
34
35
# File 'lib/celluloid/io/ssl_socket.rb', line 26

def accept
  @socket.accept_nonblock
  self
rescue ::IO::WaitReadable
  wait_readable
  retry
rescue ::IO::WaitWritable
  wait_writable
  retry
end

#connectObject


18
19
20
21
22
23
24
# File 'lib/celluloid/io/ssl_socket.rb', line 18

def connect
  @socket.connect_nonblock
  self
rescue ::IO::WaitReadable
  wait_readable
  retry
end

#to_ioObject


37
# File 'lib/celluloid/io/ssl_socket.rb', line 37

def to_io; @socket; end