class Cannon::Rpc::TcpAcceptor

Overview

Accepts connections from a TCPServer and calls TcpConnection#run for each new connection, using the passed Manager.

Call #run to start accepting connections.

Defined in:

cannon/rpc/tcp_acceptor.cr

Constructors

Instance Method Summary

Class methods inherited from class Object

to_cannon_io(io, value) to_cannon_io

Constructor Detail

def self.new(manager : Manager, server : TCPServer, tcp_nodelay : Bool = false, sync : Bool = false) #

Will accept connections from server and pass manager into the created TcpConnection.

The tcp_nodelay and sync arguments will be set in all accepted TCP connections.


[View source]

Instance Method Detail

def close #

Closes the server and stops accepting connections.


[View source]
def manager : Manager #

The used manager


[View source]
def on_new_connection(&block : TcpConnection -> Nil) #

Sets a handler called when a new connection was accepted. If you want to reject it, just call #close on the passed TcpConnection.


[View source]
def run #

Starts accepting TCP connections, blocking the current Fiber, until #close is called.


[View source]
def running? : Bool #

[View source]
def server : TCPServer #

The used tcp server


[View source]