Class: RaptorIO::Socket::TCPServer::SSL

Inherits:
RaptorIO::Socket::TCPServer show all
Defined in:
lib/raptor-io/socket/tcp_server/ssl.rb

Overview

TCP server with SSL encryption.

Author:

Instance Attribute Summary

Attributes inherited from RaptorIO::Socket

#options

Instance Method Summary collapse

Methods inherited from RaptorIO::Socket::TCPServer

#bind, #listen

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, options = {} )
  #p options[:context].frozen?
  super
  #p options[:context].frozen?

  @context = options[:context]
  if @context.nil?
    @context = OpenSSL::SSL::SSLContext.new( options[:ssl_version] )
    @context.verify_mode = options[:verify_mode]
  end

  @plaintext_socket = socket
  @socket = OpenSSL::SSL::SSLServer.new( socket, @context )
end

Instance Method Details

#acceptRaptorIO::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_nonblockRaptorIO::Socket::TCP::SSL

Accepts a client connection without blocking.

Returns:

Raises:

  • (IO::WaitWritable)

See Also:



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

#closevoid

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