Class: Async::IO::SSLServer
- Inherits:
 - 
      Object
      
        
- Object
 - Async::IO::SSLServer
 
 
- Extended by:
 - Forwardable
 
- Includes:
 - Server
 
- Defined in:
 - lib/async/io/ssl_socket.rb
 
Overview
We reimplement this from scratch because the native implementation doesn’t expose the underlying server/context that we need to implement non-blocking accept.
Instance Attribute Summary collapse
- 
  
    
      #context  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute context.
 - 
  
    
      #server  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute server.
 
Instance Method Summary collapse
- #accept(task: Task.current, timeout: nil) ⇒ Object
 - #dup ⇒ Object
 - #fileno ⇒ Object
 - 
  
    
      #initialize(server, context)  ⇒ SSLServer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of SSLServer.
 - #listen(*args) ⇒ Object
 
Methods included from Server
Constructor Details
#initialize(server, context) ⇒ SSLServer
Returns a new instance of SSLServer.
      99 100 101 102  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 99 def initialize(server, context) @server = server @context = context end  | 
  
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
      115 116 117  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 115 def context @context end  | 
  
#server ⇒ Object (readonly)
Returns the value of attribute server.
      114 115 116  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 114 def server @server end  | 
  
Instance Method Details
#accept(task: Task.current, timeout: nil) ⇒ Object
      121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 121 def accept(task: Task.current, timeout: nil) peer, address = @server.accept if timeout and peer.respond_to?(:timeout=) peer.timeout = timeout end wrapper = SSLSocket.new(peer, @context) return wrapper, address unless block_given? task.async do |task| task.annotate "accepting secure connection #{address.inspect}" begin # You want to do this in a nested async task or you might suffer from head-of-line blocking. wrapper.accept yield wrapper, address ensure wrapper.close end end end  | 
  
#dup ⇒ Object
      108 109 110  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 108 def dup self.class.new(@server.dup, @context) end  | 
  
#fileno ⇒ Object
      104 105 106  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 104 def fileno @server.fileno end  | 
  
#listen(*args) ⇒ Object
      117 118 119  | 
    
      # File 'lib/async/io/ssl_socket.rb', line 117 def listen(*args) @server.listen(*args) end  |