Created
December 10, 2017 22:03
-
-
Save ioquatix/2e522ae91c79a9aa69e3518d18b5d7f2 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/io' | |
require 'async/http/server' | |
require 'async/dns' | |
def print_server | |
Async::Reactor.run do |task| | |
task.async do | |
http_endpoints = Async::IO::Endpoint.tcp('localhost', 8081, reuse_port: true) | |
http_server = Async::HTTP::Server.new([http_endpoints]) | |
http_server.run | |
end | |
task.async do | |
dns_endpoints = Async::IO::Endpoint.udp('localhost', 5354, reuse_port: true) | |
dns_server = Async::DNS::Server.new([dns_endpoints]) | |
dns_server.run | |
end | |
task.print_hierarchy | |
# <Async::Task:0x3fef7b0c768c status=running> | |
# <Async::Task:0x3fef7b0c72e0 accepting connections #<Addrinfo: [::1]:8081 TCP> status=running> | |
# <Async::Task:0x3fef7b0c3ac8 status=complete> | |
# <Async::Task:0x3fef7b0c2f88 status=complete> | |
# <Async::Task:0x3fef7b0c2cf4 binding to #<Addrinfo: [::1]:5354 UDP (localhost)> status=running> | |
end | |
end | |
print_server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment