Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Socket.accept_loop

accept_loop(*sockets) { |socket, client_addrinfo| ... }

yield socket and client address for each a connection accepted via given sockets.

The arguments are a list of sockets. The individual argument should be a socket or an array of sockets.

This method yields the block sequentially. It means that the next connection is not accepted until the block returns. So concurrent mechanism, thread for example, should be used to service multiple clients at a time.

See also .getaddrinfo .gethostbyaddr also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0