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

Constant Summary

Constants inherited from Stream

Celluloid::IO::Stream::BLOCK_SIZE

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



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

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
# File 'lib/celluloid/io/ssl_socket.rb', line 18

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

#to_ioObject



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

def to_io; @socket; end