class IO::Socket::Async::ListenSocket
A tap for listening TCP sockets
1 | Methods |
1.1 | method socket-host |
1.2 | method socket-port |
1.3 | method native-descriptor |
2 | Type Graph |
3 | Routines supplied by class Tap |
3.1 | (Tap) method close |
is Tap
IO::Socket::Async::ListenSocket
is returned by the tap|/type/Supply#method_tap
method when called on the Supply returned by calling the listen method of IO::Socket::Async, which represents a listening TCP socket:
my IO::Socket::Async::ListenSocket =IO::Socket::Async.listen('127.0.0.1', 0).tap(->);my (Str , Int ) = await .socket-host, .socket-port;say "The rude service is listening on $host:$port for the next 10 seconds...";await Promise.in(10).then();say "I'm done now.";
Alternatively, by using the do
prefix with whenever
, you can also use it from within a react
block:
react
Methods
method socket-host
method socket-host(--> Promise)
Returns a Promise that will be kept with a Str|/type/Str
containing the address of the listening socket.
method socket-port
method socket-port(--> Promise)
Returns a Promise that will be kept with an Int|/type/Int
containing the port of the listening socket.
method native-descriptor
method native-descriptor(--> Int)
Returns the corresponding file descriptor (SOCKET
on Windows) for the listening socket.
Type Graph
Routines supplied by class Tap
IO::Socket::Async::ListenSocket inherits from class Tap, which provides the following routines:
(Tap) method close
method close(Tap:)
Closes the tap.