Sha256: 03cf0bb3406f4ee067320c1aef0f338c329936797b238f8a2aef91f8854e1f4f

Contents?: true

Size: 768 Bytes

Versions: 12

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

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

require_relative 'socket'

module Async
	module IO
		class UNIXSocket < BasicSocket
			# `send_io`, `recv_io` and `recvfrom` may block but no non-blocking implementation available.
			wraps ::UNIXSocket, :path, :addr, :peeraddr, :send_io, :recv_io, :recvfrom
			
			include Peer
		end
		
		class UNIXServer < UNIXSocket
			wraps ::UNIXServer, :listen
			
			def accept
				peer = async_send(:accept_nonblock)
				wrapper = UNIXSocket.new(peer, self.reactor)
				
				return wrapper unless block_given?
				
				begin
					yield wrapper
				ensure
					wrapper.close
				end
			end
			
			alias sysaccept accept
			alias accept_nonblock accept
		end
	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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