Class: Async::IO::SSLSocket
Overview
Asynchronous TCP socket wrapper.
Constant Summary
Constants inherited
from Generic
Generic::WRAPPERS
Instance Attribute Summary
Attributes inherited from Generic
#timeout
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Peer
#connected?, #protocol, #sync, #sync=, #type
Methods inherited from Generic
#<<, #connected?, #dup, #nonblock, #nonblock=, #nonblock?, #read, #sysread, #syswrite, #wait, wrap, wrap_blocking_method, wraps, #write
Constructor Details
#initialize(socket, context) ⇒ SSLSocket
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/async/io/ssl_socket.rb', line 64
def initialize(socket, context)
if socket.is_a?(self.class.wrapped_klass)
super
else
io = self.class.wrapped_klass.new(socket.to_io, context)
socket.reactor = nil
io.sync_close = true
@timeout = socket.timeout
super(io, socket.reactor)
end
end
|
Class Method Details
.connect(socket, context, hostname = nil, &block) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/async/io/ssl_socket.rb', line 36
def self.connect(socket, context, hostname = nil, &block)
client = self.new(socket, context)
if hostname
client.hostname = hostname
end
begin
client.connect
rescue
client.close
raise
end
return client unless block_given?
begin
yield client
ensure
client.close
end
end
|
Instance Method Details
#accept ⇒ Object
Invokes accept_nonblock on the underlying io. If the operation would block, the current task is paused until the operation can succeed, at which point it's resumed and the operation is completed.
33
|
# File 'lib/async/io/ssl_socket.rb', line 33
wrap_blocking_method :accept, :accept_nonblock
|
#close_read ⇒ Object
95
96
97
|
# File 'lib/async/io/ssl_socket.rb', line 95
def close_read
self.shutdown(Socket::SHUT_RD)
end
|
#close_write ⇒ Object
91
92
93
|
# File 'lib/async/io/ssl_socket.rb', line 91
def close_write
self.shutdown(Socket::SHUT_WR)
end
|
#connect ⇒ Object
Invokes connect_nonblock on the underlying io. If the operation would block, the current task is paused until the operation can succeed, at which point it's resumed and the operation is completed.
34
|
# File 'lib/async/io/ssl_socket.rb', line 34
wrap_blocking_method :connect, :connect_nonblock
|
#local_address ⇒ Object
83
84
85
|
# File 'lib/async/io/ssl_socket.rb', line 83
def local_address
@io.to_io.local_address
end
|
#remote_address ⇒ Object
87
88
89
|
# File 'lib/async/io/ssl_socket.rb', line 87
def remote_address
@io.to_io.remote_address
end
|
#shutdown(how) ⇒ Object
99
100
101
102
|
# File 'lib/async/io/ssl_socket.rb', line 99
def shutdown(how)
@io.flush
@io.to_io.shutdown(how)
end
|