Ruby 的 UDP 服务器简单一例

require 'socket'

s = UDPSocket.new
s.bind(nil, 1234)

5.times do
  text, sender = s.recvfrom(16)
  puts text
end

编程技巧