End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Addrinfo#listen
listen(backlog=Socket::SOMAXCONN) { |sock| ... }
ext/socket/lib/socket.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/ext/socket/lib/socket.rb, line 200
def listen(backlog=Socket::SOMAXCONN)
sock = Socket.new(self.pfamily, self.socktype, self.protocol)
begin
sock.ipv6only! if self.ipv6?
sock.setsockopt(:SOCKET, :REUSEADDR, 1) unless self.pfamily == Socket::PF_UNIX
sock.bind(self)
sock.listen(backlog)
rescue Exception
sock.close
raise
end
if block_given?
begin
yield sock
ensure
sock.close
end
else
sock
end
end
creates a listening socket bound to self.
See also
#ipv6_v4mapped?
#pfamily
#ipv6_v4compat?
#protocol
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0