On this page
class OpenSSL::SSL::SSLServer
SSLServer represents a TCP/IP server socket with Secure Sockets Layer.
Attributes
start_immediately[RW]
     
     When true then accept works exactly the same as TCPServer#accept
Public Class Methods
# File ext/openssl/lib/openssl/ssl.rb, line 368
def initialize(svr, ctx)
  @svr = svr
  @ctx = ctx
  unless ctx.session_id_context
    # see #6137 - session id may not exceed 32 bytes
    prng = ::Random.new($0.hash)
    session_id = prng.bytes(16).unpack('H*')[0]
    @ctx.session_id_context = session_id
  end
  @start_immediately = true
endCreates a new instance of SSLServer.
- srvis an instance of TCPServer.
- ctxis an instance of OpenSSL::SSL::SSLContext.
Public Instance Methods
# File ext/openssl/lib/openssl/ssl.rb, line 396
def accept
  # Socket#accept returns [socket, addrinfo].
  # TCPServer#accept returns a socket.
  # The following comma strips addrinfo.
  sock, = @svr.accept
  begin
    ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
    ssl.sync_close = true
    ssl.accept if @start_immediately
    ssl
  rescue Exception => ex
    if ssl
      ssl.close
    else
      sock.close
    end
    raise ex
  end
endWorks similar to TCPServer#accept.
# File ext/openssl/lib/openssl/ssl.rb, line 417
def close
  @svr.close
endSee IO#close for details.
# File ext/openssl/lib/openssl/ssl.rb, line 386
def listen(backlog=5)
  @svr.listen(backlog)
endSee TCPServer#listen for details.
# File ext/openssl/lib/openssl/ssl.rb, line 391
def shutdown(how=Socket::SHUT_RDWR)
  @svr.shutdown(how)
endSee BasicSocket#shutdown for details.
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.