=head2 check_connections

=cut

sub check_connections {
    my $self = shift;
    my $time = time;

    for my $connection ($self->get_all_connections) {
        if($connection->retries <= 0) {
            $self->log(warn => $connection, 'timeout');
            $self->delete_connection($connection);
        }
        elsif($connection->connected_at < $time - $self->timeout) {
            $self->log(trace => $connection, 'retry');

            if($connection->opcode == OPCODE_RRQ) {
                $self->send_data($connection);
            }
            elsif($connection->opcode == OPCODE_WRQ) {
                $self->send_ack($connection);
            }

            $connection->dec_retries;
        }
    }
}

