class Telnet::Server
- Telnet::Server
- Reference
- Object
Defined in:
telnet/server.crConstructors
-
.new(bind_address : String, bind_port : Int32, backlog : Int32 = Socket::SOMAXCONN)
Create a new Telnet server instance.
-
.new(port : Int32 = 23)
Create a new Telnet server instance.
Macro Summary
Instance Method Summary
- #backlog : Int32
- #backlog=(backlog : Int32)
- #bind_address : String
- #bind_port : Int32
-
#close
Alias of
#shutdown
-
#listen : Nil
Start the io loop and then start server to listen for incoming connections.
- #listening? : Bool
-
#on_connect(&block : Proc(Session, Nil))
Set the callback to be called when a descriptor connects.
-
#on_disconnect(&block : Proc(Session, Nil))
Set the callback to be called when a descriptor disconnects.
- #sessions : Array(Telnet::Session)
-
#shutdown
Shuts down the server socket.
Constructor Detail
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)
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)
Macro Detail
Instance Method Detail
Start the io loop and then start server to listen for incoming connections.
server = Telnet::Server.new
server.listen
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
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