Class: Mongo::Socket::SSL Private
- Inherits:
-
Mongo::Socket
- Object
- Mongo::Socket
- Mongo::Socket::SSL
- Includes:
- OpenSSL
- Defined in:
- lib/mongo/socket/ssl.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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
private
Context The ssl context.
-
#host ⇒ String
readonly
private
Host The host to connect to.
-
#host_name ⇒ String
readonly
private
Host_name The original host name.
-
#port ⇒ Integer
readonly
private
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
private
Initializes a new SSL socket.
-
#readbyte ⇒ Object
private
Read a single byte from the socket.
Methods inherited from Mongo::Socket
#alive?, #close, #connectable?, #connection_address, #connection_generation, #eof?, #gets, #monitor?, #read, #summary, #write
Constructor Details
#initialize(host, port, host_name, timeout, family, options = {}) ⇒ SSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a new SSL socket.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mongo/socket/ssl.rb', line 100 def initialize(host, port, host_name, timeout, family, = {}) super(timeout, ) @host, @port, @host_name = host, port, host_name @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)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns context The ssl context.
117 118 119 |
# File 'lib/mongo/socket/ssl.rb', line 117 def context @context end |
#host ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns host The host to connect to.
120 121 122 |
# File 'lib/mongo/socket/ssl.rb', line 120 def host @host end |
#host_name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns host_name The original host name.
123 124 125 |
# File 'lib/mongo/socket/ssl.rb', line 123 def host_name @host_name end |
#port ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns port The port to connect to.
126 127 128 |
# File 'lib/mongo/socket/ssl.rb', line 126 def port @port end |
Instance Method Details
#readbyte ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Read a single byte from the socket.
170 171 172 173 174 175 |
# File 'lib/mongo/socket/ssl.rb', line 170 def readbyte map_exceptions do byte = socket.read(1).bytes.to_a[0] byte.nil? ? raise(EOFError) : byte end end |