Class: Moped::Connection::Socket::SSL

Inherits:
OpenSSL::SSL::SSLSocket
  • Object
show all
Includes:
Connectable
Defined in:
lib/moped/connection/socket/ssl.rb

Overview

This is a wrapper around a tcp socket.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Attributes included from Connectable

#host, #port

Instance Method Summary collapse

Methods included from Connectable

#alive?, included, #read, #write

Constructor Details

#initialize(host, port) ⇒ SSL

Initialize the new TCPSocket with SSL.

Examples:

Initialize the socket.

SSL.new("127.0.0.1", 27017)

Parameters:

  • host (String)

    The host.

  • port (Integer)

    The port.

Since:

  • 1.2.0



22
23
24
25
26
27
28
29
30
# File 'lib/moped/connection/socket/ssl.rb', line 22

def initialize(host, port)
  @host, @port = host, port
  handle_socket_errors do
    @socket = TCPSocket.new(host, port)
    super(socket)
    self.sync_close = true
    connect
  end
end

Instance Attribute Details

#socketObject (readonly)

Since:

  • 2.0.0



11
12
13
# File 'lib/moped/connection/socket/ssl.rb', line 11

def socket
  @socket
end

Instance Method Details

#set_encoding(string) ⇒ Object

Set the encoding of the underlying socket.

Parameters:

  • string (String)

    The encoding.

Since:

  • 1.3.0



37
38
39
# File 'lib/moped/connection/socket/ssl.rb', line 37

def set_encoding(string)
  socket.set_encoding(string)
end

#setsockopt(*args) ⇒ Object

Set a socket option on the underlying socket.

Parameters:

  • args (Array<Object>)

    The option arguments.

Since:

  • 1.3.0



46
47
48
# File 'lib/moped/connection/socket/ssl.rb', line 46

def setsockopt(*args)
  socket.setsockopt(*args)
end