abstract class Earl::SockServer
- Earl::SockServer
- Earl::Supervisor
- Reference
- Object
Overview
A stream socket server.
- Binds to / listens on many interfaces and ports.
- Servers are spawned in a dedicated
Fiber
then supervised. - Incoming connections are handled in their own
Fiber
that runs#call(client)
and are eventually closed when the method returns or raised.
Direct Known Subclasses
Defined in:
sock_server.crInstance Method Summary
-
#add_listener(uri : String) : Nil
Adds a server based on an URI definition.
- #add_listener(uri : URI) : Nil
-
#add_ssl_listener(host : String, port : Int32, ssl_context : OpenSSL::SSL::Context::Server, *, backlog = ::Socket::SOMAXCONN) : Nil
Adds a TCP server with transparent SSL handling.
-
#add_tcp_listener(host : String, port : Int32, *, backlog = ::Socket::SOMAXCONN) : Nil
Adds a TCP server.
-
#add_unix_listener(path : String, *, mode = nil, backlog = ::Socket::SOMAXCONN) : Nil
Adds an UNIX server.
-
#call(client : Socket)
Called in a dedicated
Fiber
when a server receives a connection. - #started? : Bool
Instance methods inherited from class Earl::Supervisor
call
call,
monitor(agent : Agent) : Nil
monitor,
reset : Nil
reset,
terminate : Nil
terminate,
trap(agent : Agent, exception : Exception | Nil) : Nil
trap
Constructor methods inherited from class Earl::Supervisor
new
new
Instance methods inherited from module Earl::Logger
log
log
Class methods inherited from module Earl::Logger
backends : Array(Backend)
backends,
debug(agent : Agent, message : String) : Nildebug(agent : Agent, &block : -> String) : Nil debug, debug? : Bool debug?, error(agent : Agent, message : String) : Nil
error(agent : Agent, &block : -> String) : Nil
error(agent : Agent, ex : Exception) error, error? : Bool error?, info(agent : Agent, message : String) : Nil
info(agent : Agent, &block : -> String) : Nil info, info? : Bool info?, level : Severity level, level=(severity : Severity) : Severity level=, silent? : Bool silent?, warn(agent : Agent, message : String) : Nil
warn(agent : Agent, &block : -> String) : Nil warn, warn? : Bool warn?
Instance methods inherited from module Earl::Agent
call
call,
crashed? : Bool
crashed?,
recycle : Nil
recycle,
recycling? : Bool
recycling?,
reset : Nil
reset,
running? : Bool
running?,
spawn(*, link : Agent | Nil = nil, _yield = true) : Nil
spawn,
start(*, link : Agent | Nil = nil) : Nil
start,
starting? : Bool
starting?,
stop : Nil
stop,
stopped? : Bool
stopped?,
stopping? : Bool
stopping?,
terminate : Nil
terminate,
trap(agent : Agent, exception : Exception | Nil) : Nil
trap
Instance Method Detail
def add_listener(uri : String) : Nil
#
Adds a server based on an URI definition. For example:
server.add_listener("unix:///tmp/earl.sock")
server.add_listener("tcp://[::]:9292")
server.add_listener("ssl://10.0.3.1:443/?cert=ssl/server.crt&key=ssl/server.key")
def add_ssl_listener(host : String, port : Int32, ssl_context : OpenSSL::SSL::Context::Server, *, backlog = ::Socket::SOMAXCONN) : Nil
#
Adds a TCP server with transparent SSL handling.
Adds a TCP server.
Adds an UNIX server.
Called in a dedicated Fiber
when a server receives a connection.
Connections are closed when the method returns or raised.