Class: RaptorIO::Socket::TCPServer::SSL
- Inherits:
-
RaptorIO::Socket::TCPServer
- Object
- RaptorIO::Socket
- RaptorIO::Socket::TCPServer
- RaptorIO::Socket::TCPServer::SSL
- Defined in:
- lib/raptor-io/socket/tcp_server/ssl.rb
Overview
TCP server with SSL encryption.
Instance Attribute Summary
Attributes inherited from RaptorIO::Socket
Instance Method Summary collapse
-
#accept ⇒ RaptorIO::Socket::TCP::SSL
Accepts a client connection.
-
#accept_nonblock ⇒ RaptorIO::Socket::TCP::SSL
Accepts a client connection without blocking.
-
#close ⇒ void
Close this SSL stream and the underlying socket.
-
#initialize(socket, options = {}) ⇒ SSL
constructor
A new instance of SSL.
Methods inherited from RaptorIO::Socket::TCPServer
Methods inherited from RaptorIO::Socket
#closed?, getaddrinfo, method_missing, respond_to_missing?, select, #ssl?, #to_io, translate_errors
Constructor Details
#initialize(socket, options = {}) ⇒ SSL
Returns a new instance of SSL.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/raptor-io/socket/tcp_server/ssl.rb', line 6 def initialize( socket, = {} ) #p options[:context].frozen? super #p options[:context].frozen? @context = [:context] if @context.nil? @context = OpenSSL::SSL::SSLContext.new( [:ssl_version] ) @context.verify_mode = [:verify_mode] end @plaintext_socket = socket @socket = OpenSSL::SSL::SSLServer.new( socket, @context ) end |
Instance Method Details
#accept ⇒ RaptorIO::Socket::TCP::SSL
Accepts a client connection.
25 26 27 |
# File 'lib/raptor-io/socket/tcp_server/ssl.rb', line 25 def accept RaptorIO::Socket::TCP::SSL.from_openssl(@socket.accept) end |
#accept_nonblock ⇒ RaptorIO::Socket::TCP::SSL
Accepts a client connection without blocking.
34 35 36 |
# File 'lib/raptor-io/socket/tcp_server/ssl.rb', line 34 def accept_nonblock RaptorIO::Socket::TCP::SSL.from_openssl(@socket.accept_nonblock) end |
#close ⇒ void
This method returns an undefined value.
Close this SSL stream and the underlying socket
41 42 43 44 45 46 47 48 49 |
# File 'lib/raptor-io/socket/tcp_server/ssl.rb', line 41 def close begin @socket.close ensure if (!@plaintext_socket.closed?) @plaintext_socket.close end end end |