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.



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

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#serverObject (readonly)

Returns the value of attribute server.



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

def server
  @server
end

Instance Method Details

#accept(task: Task.current) ⇒ Object



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

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



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

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