Class: Mongo::Socket::SSL
- Inherits:
-
Mongo::Socket
- Object
- Mongo::Socket
- Mongo::Socket::SSL
- Includes:
- OpenSSL
- Defined in:
- lib/mongo/socket/ssl.rb
Overview
Wrapper for SSL sockets.
Constant Summary
Constants inherited from Mongo::Socket
SSL_ERROR, TIMEOUT_ERROR, TIMEOUT_PACK, WRITE_CHUNK_SIZE
Instance Attribute Summary collapse
-
#context ⇒ SSLContext
readonly
Context The ssl context.
-
#host ⇒ String
readonly
Host The host to connect to.
-
#host_name ⇒ String
readonly
Host_name The original host name.
-
#port ⇒ Integer
readonly
Port The port to connect to.
Attributes inherited from Mongo::Socket
#family, #options, #socket, #timeout
Instance Method Summary collapse
-
#initialize(host, port, host_name, timeout, family, options = {}) ⇒ SSL
constructor
Initializes a new SSL socket.
-
#readbyte ⇒ Object
Read a single byte from the socket.
Methods inherited from Mongo::Socket
#alive?, #close, #connectable?, #eof?, #gets, #read, #write
Constructor Details
#initialize(host, port, host_name, timeout, family, options = {}) ⇒ SSL
Initializes a new SSL socket.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/mongo/socket/ssl.rb', line 84 def initialize(host, port, host_name, timeout, family, = {}) @host, @port, @host_name, @timeout, = host, port, host_name, timeout, @context = create_context() @family = family @tcp_socket = ::Socket.new(family, SOCK_STREAM, 0) begin @tcp_socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) (@tcp_socket) connect! rescue @tcp_socket.close raise end end |
Instance Attribute Details
#context ⇒ SSLContext (readonly)
Returns context The ssl context.
25 26 27 |
# File 'lib/mongo/socket/ssl.rb', line 25 def context @context end |
#host ⇒ String (readonly)
Returns host The host to connect to.
28 29 30 |
# File 'lib/mongo/socket/ssl.rb', line 28 def host @host end |
#host_name ⇒ String (readonly)
Returns host_name The original host name.
31 32 33 |
# File 'lib/mongo/socket/ssl.rb', line 31 def host_name @host_name end |
#port ⇒ Integer (readonly)
Returns port The port to connect to.
34 35 36 |
# File 'lib/mongo/socket/ssl.rb', line 34 def port @port end |
Instance Method Details
#readbyte ⇒ Object
Read a single byte from the socket.
107 108 109 110 111 112 |
# File 'lib/mongo/socket/ssl.rb', line 107 def readbyte handle_errors do byte = socket.read(1).bytes.to_a[0] byte.nil? ? raise(EOFError) : byte end end |