Sha256: c2ace3c21d0f061b0ba8e7252f4638d602def590716075d14eb56557b7e7d2bd

Contents?: true

Size: 315 Bytes

Versions: 1

Compression:

Stored size: 315 Bytes

Contents

require 'socket'

module Kamerling
  module NetDispatcher
    module_function

    def dispatch(addr, message)
      bytes = message.to_s
      case addr.prot
      when :TCP then TCPSocket.open(*addr) { |socket| socket << bytes }
      when :UDP then UDPSocket.new.send bytes, 0, *addr
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 lib/kamerling/net_dispatcher.rb