Class: Moped::Sockets::SSL

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

Overview

This is a wrapper around a tcp socket.

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:

Since:

  • 1.2.0



21
22
23
24
25
26
27
28
29
# File 'lib/moped/sockets/ssl.rb', line 21

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)

Returns the value of attribute socket.



10
11
12
# File 'lib/moped/sockets/ssl.rb', line 10

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



36
37
38
# File 'lib/moped/sockets/ssl.rb', line 36

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

#setsockopt(*args) ⇒ Object

Set a socket option on the underlying socket.

Parameters:

Since:

  • 1.3.0



45
46
47
# File 'lib/moped/sockets/ssl.rb', line 45

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