Sha256: 10ad2a72a9d47a4b5e1bdbc83b36aa68f8e2381e738f0a37bc430e5a90ab2341
Contents?: true
Size: 988 Bytes
Versions: 12
Compression:
Stored size: 988 Bytes
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2018-2023, by Samuel Williams. require_relative 'endpoint' module Async module IO # This class will open and close the socket automatically. class AddressEndpoint < Endpoint def initialize(address, **options) super(**options) @address = address end def to_s "\#<#{self.class} #{@address.inspect}>" end attr :address # Bind a socket to the given address. If a block is given, the socket will be automatically closed when the block exits. # @yield [Socket] the bound socket # @return [Socket] the bound socket def bind(&block) Socket.bind(@address, **@options, &block) end # Connects a socket to the given address. If a block is given, the socket will be automatically closed when the block exits. # @return [Socket] the connected socket def connect(&block) Socket.connect(@address, **@options, &block) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems