class Async::IO::UNIXEndpoint
This class doesn't exert ownership over the specified unix socket and ensures exclusive access by using `flock` where possible.
Attributes
path[R]
Public Class Methods
new(path, type, **options)
click to toggle source
Calls superclass method
Async::IO::AddressEndpoint::new
# File lib/async/io/unix_endpoint.rb, line 29 def initialize(path, type, **options) # I wonder if we should implement chdir behaviour in here if path is longer than 104 characters. super(Address.unix(path, type), **options) @path = path end
Public Instance Methods
bind(&block)
click to toggle source
# File lib/async/io/unix_endpoint.rb, line 50 def bind(&block) Socket.bind(@address, **@options, &block) rescue Errno::EADDRINUSE # If you encounter EADDRINUSE from `bind()`, you can check if the socket is actually accepting connections by attempting to `connect()` to it. If the socket is still bound by an active process, the connection will succeed. Otherwise, it should be safe to `unlink()` the path and try again. if !bound? && File.exist?(@path) File.unlink(@path) retry else raise end end
bound?()
click to toggle source
# File lib/async/io/unix_endpoint.rb, line 42 def bound? self.connect do return true end rescue Errno::ECONNREFUSED return false end
to_s()
click to toggle source
# File lib/async/io/unix_endpoint.rb, line 36 def to_s "\#<#{self.class} #{@path.inspect}>" end