Documentation for method listen

Documentation for method listen, assembled from the following types:

class IO::Socket::Async

From IO::Socket::Async

(IO::Socket::Async) method listen

method listen(Str $hostInt $port --> Supply)

Creates a listening socket on the specified $host and $port, returning a Supply to which the accepted client IO::Socket::Asyncs will be emitted. This Supply should be tapped start listening for client connections.

To close the underlying listening socket, the Tap returned by tapping the listener should be closed.

For example, when using tap:

my $listener = IO::Socket::Async.listen(''8080);
my $tap = $listener.tap({ ... });
# When you want to close the listener 

Or when using whenever:

my $listener = IO::Socket::Async.listen(''5000);
my $big-finish =;
my $tap = do whenever $listener -> $conn { ... }
await $big-finish;