Sha256: 0c41e8a0bd22d9cb26d45b71bbec5d7cdf8b4fa2736dd187eda38d738b2a08b6
Contents?: true
Size: 855 Bytes
Versions: 1
Compression:
Stored size: 855 Bytes
Contents
# frozen_string_literal: true module Socketry # User Datagram Protocol: "fire-and-forget" packet protocol module UDP # Represents a received UDP message class Datagram attr_reader :message, :sockaddr, :host, :addr, :port def initialize(message, sockaddr) @message = message @sockaddr = sockaddr @port = sockaddr[1] @host = sockaddr[2] @addr = sockaddr[3] end def addrinfo addr_family = case @sockaddr[0] when "AF_INET" then ::Socket::AF_INET when "AF_INET6" then ::Socket::AF_INET6 else raise Socketry::AddressError, "unsupported IP address family: #{@sockaddr[0]}" end Addrinfo.new(@sockaddr, addr_family, ::Socket::SOCK_DGRAM) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
socketry-0.4.0 | lib/socketry/udp/datagram.rb |