A basic wrapper over Ruby's SSLSocket that initiates a TCP connection over SSL and then provides an basic interface mirroring Ruby's TCPSocket, vis., TCPSocket#send and TCPSocket#read.
# File lib/mongo/util/ssl_socket.rb, line 14 def initialize(host, port, op_timeout=nil, connect_timeout=nil) @op_timeout = op_timeout @connect_timeout = connect_timeout @pid = Process.pid @socket = ::TCPSocket.new(host, port) @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) @ssl = OpenSSL::SSL::SSLSocket.new(@socket) @ssl.sync_close = true connect end
# File lib/mongo/util/ssl_socket.rb, line 52 def close @ssl.close end
# File lib/mongo/util/ssl_socket.rb, line 56 def closed? @ssl.closed? end
# File lib/mongo/util/ssl_socket.rb, line 28 def connect if @connect_timeout Timeout::timeout(@connect_timeout, ConnectionTimeoutError) do @ssl.connect end else @ssl.connect end end
Generated with the Darkfish Rdoc Generator 2.