Sha256: bdcfd58a458384d1fdffb963d5c720263d6239ce5d46550b4420c66918491ed6

Contents?: true

Size: 789 Bytes

Versions: 12

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2017-2023, by Samuel Williams.

require_relative 'socket'

module Async
	module IO
		# Asynchronous UDP socket wrapper.
		class UDPSocket < IPSocket
			wraps ::UDPSocket, :bind
			
			def initialize(family)
				if family.is_a? ::UDPSocket
					super(family)
				else
					super(::UDPSocket.new(family))
				end
			end
			
			# We pass `send` through directly, but in theory it might block. Internally, it uses sendto.
			def_delegators :@io, :send, :connect
			
			# This function is so fucked. Why does `UDPSocket#recvfrom` return the remote address as an array, but `Socket#recfrom` return it as an `Addrinfo`? You should prefer `recvmsg`.
			wrap_blocking_method :recvfrom, :recvfrom_nonblock
		end
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
async-io-1.43.2 lib/async/io/udp_socket.rb
async-io-1.43.1 lib/async/io/udp_socket.rb
async-io-1.43.0 lib/async/io/udp_socket.rb
async-io-1.42.1 lib/async/io/udp_socket.rb
async-io-1.42.0 lib/async/io/udp_socket.rb
async-io-1.41.0 lib/async/io/udp_socket.rb
async-io-1.39.0 lib/async/io/udp_socket.rb
async-io-1.38.1 lib/async/io/udp_socket.rb
async-io-1.38.0 lib/async/io/udp_socket.rb
async-io-1.37.0 lib/async/io/udp_socket.rb
async-io-1.36.1 lib/async/io/udp_socket.rb
async-io-1.36.0 lib/async/io/udp_socket.rb