Net-Clacks

 view release on metacpan or  search on metacpan

lib/Net/Clacks/Client.pm  view on Meta::CPAN

    # Maximum time to spend trying to drain the outbuffer when the server isn't
    # reading (kernel send buffer full -> syswrite returns EAGAIN repeatedly).
    # Tracked in doNetwork() via writefailtime; on expiry the connection is
    # marked for reconnect. This is the symmetric counterpart of the server's
    # stalledwritetimeout and is what stops the many "send loop" sites that
    # otherwise spin forever when the server is alive but not consuming.
    $self->{stalledwritetimeout} = 30;

    # TCP connect timeout. Without this, a TCP connect to an unreachable host
    # waits for the kernel SYN-retransmit timeout (~75 s on Linux) before
    # giving up. Defaulted generously so a transiently-busy server (full
    # listen backlog, scheduler delays under load) or a slow link doesn't
    # produce false-positive failures. Unix-domain sockets are not affected —
    # connect there fails or succeeds immediately.
    $self->{connecttimeout} = 60;

    # TLS handshake timeout. Implemented via deferred handshake + IO::Select
    # polling so we don't depend on SIGALRM, which is unsafe in applications
    # that already use signals or have their own event loop. Defaulted
    # generously to tolerate slow servers (RSA signing on a small CPU is not
    # instant) and high-RTT links.

lib/Net/Clacks/Server.pm  view on Meta::CPAN

    }
    return;
}

sub _addNewClients($self) {
    my $now = $self->_getTime();
    foreach my $tcpsocket (@{$self->{tcpsockets}}) {
        # Drain the listen queue rather than accepting one connection per iteration.
        # The listener is non-blocking, so accept() returns undef once the queue is empty.
        # This prevents a burst of connects from being rejected at the kernel level when
        # the backlog fills up while the main loop is busy elsewhere.
        my $acceptedThisCycle = 0;
        while(1) {
            # Hard cap to keep one rogue burst from monopolising the loop and starving
            # existing clients. Any remaining pending connects will be picked up in the
            # next runOnce() iteration.
            last if($acceptedThisCycle >= 64);

            my $clientsocket = $tcpsocket->accept;
            if(!defined($clientsocket)) {
                # EAGAIN/EWOULDBLOCK (no more pending) or a transient error like

lib/Net/Clacks/Server.pm  view on Meta::CPAN

DEPRECATED: Initialize server instance (required before running). This is now a dummy function that will show a deprecation warning and return.
Initialization is now done automatically when calling run().

=head2 run

Run the server instance in it's own event loop. Only returns when server is shutdown.

=head2 runOnce

Run through the event loop once. This allows you to use your own programs event loop, and call runOnce a couple of times per second. It is a good idea to call runShutdown() to cleanly
disconnect clients before exiting your program. runOnce() returns a "work count" number, on which you *may* decide on how busy the server is and when to call runOnce() next.

=head2 runShutdown

Shuts down all connections. This is called automatically if you use run(), but not if you use runOnce()

=head1 IMPORTANT NOTE

Please make sure and read the documentations for L<Net::Clacks> as it contains important information
pertaining to upgrades and general changes!

lib/Net/Clacks/UpgradeGuide.pod  view on Meta::CPAN

=head2 VERSION 35

This version retunes some timeouts that may or may not have caused problems in the past.

It now also provides more automated tests and a documentation of the protocol.

This version is fully backwards compatible to Version 34, minus the bugs i hopefully managed to squash.

=head2 VERSION 36

This version squashes some long standing bugs regarding connection management. Very busy servers should now run more stable.

This version is fully backwards compatible to Version 34, minus the bugs i hopefully managed to squash.

=head1 AUTHOR

Rene Schickbauer, E<lt>cavac@cpan.orgE<gt>

=head1 Source code repository

The official source code repository is located at:



( run in 3.138 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )