Skip to content

Instantly share code, notes, and snippets.

@ioquatix
Last active August 1, 2020 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioquatix/87dd029c060d273df0da479d30009745 to your computer and use it in GitHub Desktop.
Save ioquatix/87dd029c060d273df0da479d30009745 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'async'
require 'async/io/unix_endpoint'
endpoint = Async::IO::Endpoint.unix("foo.ipc")
fork do
Async do
endpoint.accept do |peer|
Console.logger.info(peer, "sleep 1")
Async::Task.current.sleep(1)
Console.logger.info(peer, "sepukku")
Process.kill(:KILL, Process.pid)
end
end
end
sleep 1
Async do
endpoint.connect do |peer|
Console.logger.info(peer, "read")
puts peer.read.inspect
rescue
Console.logger.error(peer, $!)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment