-
-
Save flano-yuki/4e70d4d38da87018d4ed8c035d27b765 to your computer and use it in GitHub Desktop.
This file contains 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/ruby | |
require "socket" | |
require 'timeout' | |
udps = [] | |
5.times do | |
udps << UDPSocket.open() | |
end | |
addrs = [] | |
5.times do | |
addrs << Socket.pack_sockaddr_in(10000, "NLB Endpoint") #編集 | |
end | |
while true do | |
5.times do |i| | |
begin | |
Timeout.timeout(3) do | |
udps[i].send("HELLO", 0, addrs[i]) | |
print "#{udps[i].recv(65535)} " | |
end | |
rescue Timeout::Error | |
print '(timeout) ' | |
end | |
end | |
puts "" | |
sleep 3 | |
end | |
This file contains 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/ruby | |
require "socket" | |
host = Socket.gethostname | |
Socket.udp_server_loop(10000) do |data, src| | |
src.reply host | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment