Sha256: 3bc871790654cb711f6306b2224bc6a245f9808b19d546c1bc91e8769973681e

Contents?: true

Size: 466 Bytes

Versions: 2

Compression:

Stored size: 466 Bytes

Contents

module Kamerling module Server class UDP < Sock
  private

  def handle_connection socket
    input, conn = socket.recvfrom 2**16
    client_addr = Addr[conn[3], conn[1], :UDP]
    handle input, client_addr
  end

  def run_loop
    socket = UDPSocket.new.tap { |server| server.bind(*addr) }
    loop { handle_connection socket if IO.select [socket] }
  ensure
    socket.close if socket
  end

  def wait_till_started
    200.times { thread.run }
  end
end end end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kamerling-0.0.2 lib/kamerling/server/udp.rb
kamerling-0.0.1 lib/kamerling/server/udp.rb