Class: Celluloid::IO::SSLSocket

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

Overview

SSLSocket with Celluloid::IO support

Constant Summary

Constants inherited from Socket

Celluloid::IO::Socket::Constants

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

Methods inherited from Socket

new, #to_io, try_convert

Constructor Details

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

Returns a new instance of SSLSocket.



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

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

Instance Method Details

#acceptObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/celluloid/io/ssl_socket.rb', line 35

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

#connectObject



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

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