Class: Async::IO::SSLServer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ServerSocket
Defined in:
lib/async/io/ssl_socket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ServerSocket

#accept_each

Constructor Details

#initialize(server, context) ⇒ SSLServer

Returns a new instance of SSLServer.



58
59
60
61
# File 'lib/async/io/ssl_socket.rb', line 58

def initialize(server, context)
	@server = server
	@context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



66
67
68
# File 'lib/async/io/ssl_socket.rb', line 66

def context
  @context
end

#serverObject (readonly)

Returns the value of attribute server.



65
66
67
# File 'lib/async/io/ssl_socket.rb', line 65

def server
  @server
end

Instance Method Details

#accept(task: Task.current) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/async/io/ssl_socket.rb', line 74

def accept(task: Task.current)
	peer, address = @server.accept
	
	wrapper = SSLSocket.connect_socket(peer, @context)
	
	if block_given?
		task.async do
			task.annotate "accepting secure connection #{address}"
			
			begin
				wrapper.accept
				
				yield wrapper, address
			rescue SSLError
				Async.logger.error($!.class) {$!}
			ensure
				wrapper.close
			end
		end
	else
		return wrapper, address
	end
end

#listen(*args) ⇒ Object



70
71
72
# File 'lib/async/io/ssl_socket.rb', line 70

def listen(*args)
	@server.listen(*args)
end