Class: Net::Tofu::Socket
- Inherits:
-
Object
- Object
- Net::Tofu::Socket
- Defined in:
- lib/net/tofu/socket.rb
Overview
Stoes an SSLSocket for making requests and receiving data.
Instance Method Summary collapse
-
#close ⇒ Object
Close the connection with the server.
-
#connect ⇒ Object
Open a connection to the server.
-
#gets(req) ⇒ Object
Try and retrieve data from a request.
-
#initialize(host, port, trust) ⇒ Socket
constructor
Constructor for the socket type.
Constructor Details
#initialize(host, port, trust) ⇒ Socket
Constructor for the socket type.
10 11 12 13 14 15 |
# File 'lib/net/tofu/socket.rb', line 10 def initialize(host, port, trust) @host = host @port = port @trust = trust @sock = OpenSSL::SSL::SSLSocket.open(@host, @port, context: generate_secure_context) end |
Instance Method Details
#close ⇒ Object
Close the connection with the server.
39 40 41 |
# File 'lib/net/tofu/socket.rb', line 39 def close @sock.close end |
#connect ⇒ Object
Open a connection to the server.
18 19 20 21 22 |
# File 'lib/net/tofu/socket.rb', line 18 def connect @sock.hostname = @host @sock.connect validate_certs end |