Sha256: 0dc19092d6968baca6bf64578a1833bfa14a4cdf2f8c9c9e9ada1b0d45f0a258

Contents?: true

Size: 549 Bytes

Versions: 2

Compression:

Stored size: 549 Bytes

Contents

require "bundler/setup"
require "celluloid/io"

class EchoUNIXClient
  include Celluloid::IO
  finalizer :finalize

  def initialize(socket_path)
    puts "*** connecting to #{socket_path}"
    @socket_path = socket_path
    @socket = UNIXSocket.open(socket_path)
  end

  def echo(msg)
    puts "*** send to server: '#{msg}'"
    @socket.puts(msg)
    data = @socket.readline.chomp
    puts "*** server unswer '#{data}'"
    data
  end

  def finalize
    @socket.close if @socket
  end
end

c = EchoUNIXClient.new("/tmp/sock_test")
c.echo("DATA")

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-io-0.17.3 examples/echo_unix_client.rb
celluloid-io-0.17.2 examples/echo_unix_client.rb