This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
tserver /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
CHANGELOG | ||
| |
LICENSE | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
lib/ | ||
| |
test/ |
README.rdoc
TServer
| Author: | Yann Lugrin (yann.lugrin at sans-savoir dot net) |
| Copyright: | Copyright © 2007-2008 Yann Lugrin |
| Licence: | MIT |
| Last version: | 0.2.0 |
This librarie implements a persistant multithread TCP server, it is alternative to ‘gserver' standard librarie. TServer is designed to be inherited by your custom server class. The server can accepts multiple simultaneous connections from clients, can be configured to have a maximum connection and a minimum permanent listener thread. Can be imediatly stopped, gracefull shutdown (dont accept new connection but wait established connection is closed before realy stop) or reloaded (terminate listener after established connection is closed and respawn new).
Example
This example can receive and return simple string from telnet connection.
require 'tserver'
class ExampleServer < TServer
class Listener < TServer::Listener
def process
connection.each do |line|
break if line =~ /(quit|exit|close)/
log '> ' + line.chomp
conn.puts Time.now.to_s + '> ' + line.chomp
end
end
end
end
# Create the server with logging enabled (server activity is displayed
# in console with received data)
server = ExampleServer.new
server.verbose = true
# Shutdown the server when script is interupted
Signal.trap('SIGINT') do
server.shutdown
end
# Start the server (joined is set to true and the line wait on server
# thread before continue, the default values of this parameter is set to
# false, you can also use 'server.join' after server.start)
server.start(true)
# Now you can open a telnet connection to 127.0.0.1:10001 (telnet 127.0.0.1 10001)
# and send text (use exit to close the connection)








