class

Beryl::TLS::Server

Inherits Socket::Server < Reference < Object

Wraps a ::Socket::Server (such as a TCPServer) so each accepted connection is a Socket::Server, as OpenSSL::SSL::Server does. HTTP::Server#bind(server) takes it on stock Crystal.

tcp_server = TCPServer.new("0.0.0.0", 8443)
http_server.bind(Beryl::TLS::Server.new(tcp_server, context))

Constructors

new(wrapped : ::Socket::Server, context : Context::Server, sync_close : Bool = true)
Source

Instance methods

accept

Accepts an incoming connection and returns the client socket.

require "socket"

server = TCPServer.new(2202)
while true
  socket = server.accept
  socket.puts Time.utc
  socket.close
end

If the server is closed after invoking this method, an IO::Error (closed stream) exception must be raised.

Source
accept?

Accepts an incoming connection and returns the client socket.

Returns nil if the server is closed after invoking this method.

require "socket"

server = TCPServer.new(2202)
while socket = server.accept?
  socket.puts Time.utc
  socket.close
end
Source
close
Source
context
Source
local_address
Source
start_immediately

Whether the handshake runs in accept; off by default, so the handshake runs in the connection's own fiber on first use.

Source
start_immediately=(start_immediately : Bool)

Whether the handshake runs in accept; off by default, so the handshake runs in the connection's own fiber on first use.

Source
sync_close=(sync_close : Bool)
Source
sync_close?
Source
tcp_nodelay=(tcp_nodelay : Bool)

Whether each accepted TCPSocket gets TCP_NODELAY; on by default. Each WebSocket message or HTTP response goes out as one TLS record in one write, and with Nagle on a small write waits for the ACK of the one before it, which a peer delaying its ACKs holds back for up to 40 ms on Linux. Turn it off only for a server that writes few, large records.

Source
tcp_nodelay?

Whether each accepted TCPSocket gets TCP_NODELAY; on by default. Each WebSocket message or HTTP response goes out as one TLS record in one write, and with Nagle on a small write waits for the ACK of the one before it, which a peer delaying its ACKs holds back for up to 40 ms on Linux. Turn it off only for a server that writes few, large records.

Source
wrapped
Source