Last active
August 1, 2020 06:11
-
-
Save ioquatix/87dd029c060d273df0da479d30009745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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