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 , Int --> 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. You can use $port = 0 if you want the operating system to find one for you.
To close the underlying listening socket, the Tap returned by tapping the listener should be closed.
For example, when using tap:
my = IO::Socket::Async.listen('127.0.0.1', 8080);my = .tap();# When you want to close the listener.close;
Or when using whenever:
my = IO::Socket::Async.listen('127.0.0.1', 5000);my ;react# When you want to close the listener, you can still use:.close;