Sha256: efa9328d7ad4d29512fc09b2daec832bb646966928adb7b85c7d02cce2d0fed8
Contents?: true
Size: 803 Bytes
Versions: 3
Compression:
Stored size: 803 Bytes
Contents
require 'bundler/setup' require 'celluloid/io' class EchoUNIXServer include Celluloid::IO attr_reader :socket_path, :server def initialize(socket_path) puts "*** start server #{socket_path}" @socket_path = socket_path @server = UNIXServer.open(socket_path) async.run end def run loop { async.handle_connection @server.accept } end def handle_connection(socket) loop do data = socket.readline puts "*** gets data #{data}" socket.write(data) end rescue EOFError puts "*** disconnected" ensure socket.close end def finalize if @server @server.close File.delete(@socket_path) end end end supervisor = EchoUNIXServer.supervise("/tmp/sock_test") trap("INT") { supervisor.terminate; exit } sleep
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
celluloid-io-0.13.1 | examples/echo_unix_server.rb |
celluloid-io-0.13.0 | examples/echo_unix_server.rb |
celluloid-io-0.13.0.pre2 | examples/echo_unix_server.rb |