lib/async/io/ssl_socket.rb in async-io-1.22.0 vs lib/async/io/ssl_socket.rb in async-io-1.23.0
- old
+ new
@@ -31,13 +31,10 @@
wraps ::OpenSSL::SSL::SSLSocket, :alpn_protocol, :cert, :cipher, :client_ca, :context, :getsockopt, :hostname, :hostname=, :npn_protocol, :peer_cert, :peer_cert_chain, :pending, :post_connection_check, :setsockopt, :session, :session=, :session_reused?, :ssl_version, :state, :sync_close, :sync_close=, :sysclose, :verify_result, :tmp_key
wrap_blocking_method :accept, :accept_nonblock
wrap_blocking_method :connect, :connect_nonblock
- alias syswrite write
- alias sysread read
-
def self.connect(socket, context, hostname = nil, &block)
client = self.new(socket, context)
# Used for SNI:
if hostname
@@ -60,18 +57,10 @@
ensure
client.close
end
end
- def local_address
- @io.to_io.local_address
- end
-
- def remote_address
- @io.to_io.remote_address
- end
-
include Peer
def initialize(socket, context)
if socket.is_a?(self.class.wrapped_klass)
super
@@ -87,9 +76,30 @@
# Copy the timeout:
@timeout = socket.timeout
super(io, socket.reactor)
end
+ end
+
+ def local_address
+ @io.to_io.local_address
+ end
+
+ def remote_address
+ @io.to_io.remote_address
+ end
+
+ def close_write
+ self.shutdown(Socket::SHUT_WR)
+ end
+
+ def close_read
+ self.shutdown(Socket::SHUT_RD)
+ end
+
+ def shutdown(how)
+ @io.flush
+ @io.to_io.shutdown(how)
end
end
# We reimplement this from scratch because the native implementation doesn't expose the underlying server/context that we need to implement non-blocking accept.
class SSLServer