Last active
March 27, 2017 20:51
-
-
Save elorest/95256e5cb450e3b25ccf28a2fc5707e4 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
require "socket" | |
UNIXSocket.open("/tmp/cr.sock") do |sock| | |
puts "What is your name?" | |
name = gets | |
sock.puts name | |
puts sock.gets | |
sock.close | |
end |
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
require "socket" | |
server = UNIXServer.new("/tmp/cr.sock") | |
while sock = server.accept | |
# proc = ->(sock : UNIXSocket) do | |
spawn do | |
name = sock.gets | |
puts name | |
sock.puts "Hello #{name}." | |
sock.close | |
end | |
# end | |
# proc.call(sock) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment