NAME

Net::Async::Kubernetes::PortForwardListener - Local TCP listeners forwarding to pod ports, like kubectl port-forward

VERSION

version 0.011

SYNOPSIS

my $listener = $kube->port_forward_listen('Pod', 'web',
    namespace => 'default',
    ports     => { 0 => 80 },
    on_error  => sub { warn "forward: $_[0]\n" },
)->get;

my $port = $listener->port_for(80);
# ... talk HTTP to 127.0.0.1:$port ...
$listener->stop;

DESCRIPTION

The handle "port_forward_listen" in Net::Async::Kubernetes resolves with. It owns the local listening sockets and, for every accepted TCP connection, one port-forward session of its own (see "port_forward" in Net::Async::Kubernetes) for the remote port the local port maps to. Bytes read from the connection are written to the session's data channel and bytes from the pod written back to the connection. The connection and the session end together.

new

Built by "port_forward_listen" in Net::Async::Kubernetes, which validates its arguments; there is no reason to call this directly.

port_for

my $local = $listener->port_for(8080);

The local TCP port that forwards to remote $remote: the one given in ports, or the one the system picked for a local port of 0. undef for a remote port that is not forwarded.

host

The local address the listeners are bound to.

connection_count

The number of forwarded connections currently open.

stop

$listener->stop;

Close the listening sockets and every open connection, together with its port-forward session. Safe to call more than once. The listener cannot be restarted; open a new one.

SEE ALSO

Net::Async::Kubernetes, Net::Async::Kubernetes::PortForwardSession, IO::Async::Listener

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-net-async-kubernetes/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.