Net-QUIC
view release on metacpan or search on metacpan
lib/Net/QUIC/Driver.pm view on Meta::CPAN
);
my $connection = $driver->connection;
$driver->start;
From the UDP read callback:
$driver->receive($bytes, $local, $peer);
From the timer callback:
$driver->timeout;
If UDP sending had become blocked and later recovers:
$driver->writable;
=head1 DRIVER OR ENDPOINT?
Use Driver unless you have a specific reason not to.
L<Net::QUIC::Endpoint> is the lower-level engine underneath Driver. Endpoint
makes the caller manually drain output and maintain the QUIC timer.
Driver does that bookkeeping for you.
=head1 CONSTRUCTORS
=head2 client
my $driver = Net::QUIC::Driver->client(
local => $local,
peer => $peer,
alpn => 'my-protocol',
server_name => 'example.com',
send => sub { ... },
set_timeout => sub { ... },
);
Creates a client Driver.
C<local> is the packed local UDP socket address.
C<peer> is the packed server UDP address.
C<alpn> is the application protocol name that client and server agree to use.
C<server_name> is the DNS name or IP address expected in the server
certificate.
Other client options are passed to L<Net::QUIC::Endpoint/client>. This includes
session resumption, 0-RTT, address-token reuse, QUIC version selection, and
transport limits.
=head2 server
my $driver = Net::QUIC::Driver->server(
alpn => 'my-protocol',
certificate_file => 'server-cert.pem',
private_key_file => 'server-key.pem',
send => sub { ... },
set_timeout => sub { ... },
);
Creates a server Driver.
One server Driver can manage many QUIC Connections on one UDP socket.
Pull newly created Connections with L</next_connection>.
Other server options are passed to L<Net::QUIC::Endpoint/server>.
=head2 new
my $driver = Net::QUIC::Driver->new(
endpoint => $endpoint,
send => sub { ... },
set_timeout => sub { ... },
);
Wraps an existing Endpoint-compatible object.
Most code should use C<client> or C<server> instead.
=head1 ADAPTER CALLBACKS
=head2 send
send => sub {
my ($datagram) = @_;
...
return 1;
}
Receives one complete L<Net::QUIC::Datagram>.
Useful values are:
$datagram->data
$datagram->local
$datagram->peer
$datagram->ecn
C<data> is one complete UDP payload. Do not split it.
C<peer> is the destination address.
C<local> is the local source address QUIC expects for that packet.
For a socket bound to one concrete local address, the socket normally already
uses the right source address.
For a wildcard-bound socket or a migrating connection, the adapter may need a
platform-specific source-address mechanism such as C<sendmsg> packet
information.
The callback return value controls output flow:
=over 4
( run in 1.591 second using v1.01-cache-2.11-cpan-036bef1c656 )