class Telnet::Server

Defined in:

telnet/server.cr

Constructors

Macro Summary

Instance Method Summary

Constructor Detail

def self.new(bind_address : String, bind_port : Int32, backlog : Int32 = Socket::SOMAXCONN) #

Create a new Telnet server instance. @bind_address is the IP address to bind the server to. @bind_port is the port to bind the server to.

server = Telnet::Server.new("0.0.0.0", 9099)

[View source]
def self.new(port : Int32 = 23) #

Create a new Telnet server instance. #bind_address defaults to 127.0.0.1 port defaults to 23

server = Telnet::Server.new

or

server = Telnet::Server.new(9099)

[View source]

Macro Detail

macro method_missing(call) #

[View source]

Instance Method Detail

def backlog : Int32 #

[View source]
def backlog=(backlog : Int32) #

[View source]
def bind_address : String #

[View source]
def bind_port : Int32 #

[View source]
def close #

Alias of #shutdown


[View source]
def listen : Nil #

Start the io loop and then start server to listen for incoming connections.

server = Telnet::Server.new
server.listen

[View source]
def listening? : Bool #

[View source]
def on_connect(&block : Proc(Session, Nil)) #

Set the callback to be called when a descriptor connects. The callback will be passed the descriptor descriptor. The callback yields the descriptor.

server.on_connect do |descriptor|
 puts "descriptor connected from #{descriptor.remote_address}"
end

[View source]
def on_disconnect(&block : Proc(Session, Nil)) #

Set the callback to be called when a descriptor disconnects. The callback will be passed the descriptor. The callback yields the descriptor.

server.on_disconnect do |descriptor|
  puts "descriptor disconnected from #{descriptor.remote_address}"
end

[View source]
def sessions : Array(Telnet::Session) #

[View source]
def shutdown #

Shuts down the server socket.


[View source]