Socket
Book a DemoInstallSign in
Socket

tserver

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tserver

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

= TServer

Author:: Yann Lugrin (mailto:yann.lugrin@sans-savoir.net) Copyright:: Copyright (c) 2007 Yann Lugrin Licence:: MIT[link://files/LICENSE.html] Version:: 0.2.0

This librarie implements a persistant multithread TCP server, it is alternative to 'gserver'[http://ruby-doc.org/stdlib/libdoc/gserver/rdoc/index.html] 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 simple string from telnet connection

require 'tserver'

A server can return

class ExampleServer < TServer 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

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)

FAQs

Package last updated on 25 Jul 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.