Sha256: a5596665530d673dfc1a48a18b5e44a8c7ef59975afcacdd7b8896348f275154
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'tools.rb' module Secure class Client def initialize(socket) @socket=socket @data="" end def send(*m) end def register(&b) end def run @thread=Thread.new { begin loop do @data+=@socket.read(1024) check end rescue Exception=>e log e,e.backtrace end } end private def check end end class Server attr_reader :clients def initialize(port,host="localhost") @port=port @host=host addr= Socket.pack_sockaddr_in( @port,@host) @server=TCPServer.new(port,addr) @clients=[] @mainThread=nil @mutex=Mutex.new end def clients @mutex.synchronize { @clients.dup } end def kill @mainThread.kill if @mainThread end def run @mainThread=Thread.new { client=@server.accept c=Client.new(client) @mutex.synchronize { @clients<<c } begin c.run rescue Exception=>e log e @mutex.synchronize { @clients.delete(c) } end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | lib/appswarm/secure_connection.rb |