Code Monkey home page Code Monkey logo

anyevent-handle-udp's People

Contributors

leont avatar sergle avatar tanami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cosimo sergle tanami

anyevent-handle-udp's Issues

destroy within on_recv produce error

I want to shutdown the handle when i encounter some strange behavior in on_recv(), so i call destroy() ... but this produce an error recv() on closed socket GEN24 at /path/to/AnyEvent/Handle/UDP.pm line 151.

Perhaps there should be a check at line 151 if $self->{reader} still exists?

while (exists($self->{reader}) and defined (my $addr = recv $self->{fh}, ...) {

Unable to stop timeout

on_timeout keep executing even after Handle ->destroy

#! perl

use strict;
use warnings FATAL   => 'all';
use Test::More tests => 2;
use AnyEvent::Handle::UDP;
use Socket qw/unpack_sockaddr_in/;
use IO::Socket::INET;

alarm 6;

{

    my $addr = inet_aton('localhost');
    socket my $socket, PF_INET, SOCK_DGRAM, 0
      or die "Unable to create socket: $!";
    connect $socket, pack_sockaddr_in(0, $addr) or die "connect: $!";
    my $sockaddr = getsockname $socket;

    my $client;
    my $cb = sub {
        is shift, "TIMEOUT", 'first client timed out';
        $client->destroy;
    };

    $client = AnyEvent::Handle::UDP->new(
        connect    => $sockaddr,
        on_recv    => $cb,
        on_error   => $cb,
        timeout    => 1,
        on_timeout => sub { $cb->("TIMEOUT"); return; },
    );

    my $cb2    = AE::cv;
    my $client2 = AnyEvent::Handle::UDP->new(
        connect    => $sockaddr,
        on_recv    => $cb2,
        on_error   => $cb2,
        timeout    => 4,
        on_timeout => sub { $cb2->("TIMEOUT"); return; },
    );

    $client->push_send('test');
    $client2->push_send('test');

    is(
        $cb2->recv,
        "TIMEOUT",
        'second client timed out'
    );
}

Uncaught error on sending to the closed port

Hello,
I have an issue with latest versions (later than 0.043), if I am trying to send some message to closed port it just generates uncagh error. Not able to handle this using on_error.
Also this test works correctly with older version 0.043
Tests:

#! perl

use strict;
use warnings FATAL   => 'all';
use Test::More tests => 1;
use AnyEvent::Handle::UDP;
use Socket qw/unpack_sockaddr_in/;
use IO::Socket::INET;

alarm 3;

{

    my $addr = inet_aton('localhost');
    socket my $socket, PF_INET, SOCK_DGRAM, 0
      or die "Unable to create socket: $!";

    connect $socket, pack_sockaddr_in(0, $addr) or die "connect: $!";

    my $sockaddr_closed = getsockname $socket;
    close $socket or die "close: $!";

    my $cb     = AE::cv;
    my $client = AnyEvent::Handle::UDP->new(
        connect  => $sockaddr_closed,
        on_recv  => $cb,
        on_error => sub { $cb->send($_[2]) },
        timeout => 2,
        on_timeout => $cb,
    );
    $client->push_send("test");
    is($cb->recv, "Couldn't recv: Connection refused", 'Got connection refused error');
}

Version 0.031 push_send problem

Hi, I tried to use this module, but didn't work as expected.
I guess _send() in push_send should be _send($message, $to)

please make sure of it.

Cheers,

BEFORE

sub push_send {
    my ($self, $message, $to) = @_;
    my $ret = $self->_send();
    $self->_push_writer($message, $to) if not defined $ret and ($! == EAGAIN or $! == EWOULDBLOCK);
    return;
}

AFTER

sub push_send {
    my ($self, $message, $to) = @_;
    my $ret = $self->_send($message, $to);
    $self->_push_writer($message, $to) if not defined $ret and ($! == EAGAIN or $! == EWOULDBLOCK);
    return;
}

error due to nameserver resolving delay

Hi,

when using AnyEvent::Handle::UDP with a hostname in the connect argument there is (ofc) a short delay till the handle is working properly.

For the first push_send i reveice the following error:
Bad filehandle: GEN0 at /path/to/AnyEvent/Handle/UDP.pm line 288.

Perhaps there should be some kind of queueing or at least a better error message, when using a hostname and imitiatly use the handle and the fh is not ready.

on_connect callback does not pass any useful arguments

please consider passing $self so that it is possible to use it as a client module.

Also, the use of the ::Handle namespace is very confusing as it implies that ::Handle::UDP is a subclass of AnyEvent::Handle, I was very surprised when it was not!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.