AE::MP::DataConn -

gleeco gleeco at gmail.com
Fri Jun 15 08:15:03 CEST 2012


Am extra eyes on why AE::MP::DataConn does not work.  If a single
push_write(), then it just hangs, but if 1+ push_write() it barfs
'connection reset by peer'.
Basically, the std. aemp stuff works, just not the handle pushes as
described in the perlpod.

what else?  Looking at the DataConn.pm, it is unclear why the address is
shifted/deleted from %AE::MP::Global::addr  --thus making any 'global'
reuse of that addr useless.  Intended?
eg.

   my $addr = $AnyEvent::MP::Global::addr{$node};

   @$addr
      or return $state->{done}(undef, "$node: no listeners found");

   # I love hardcoded constants  !
   $state->{next} = AE::timer 0, 2, sub {
      my $endpoint = shift @$addr


Am i missing something obvious?  I would love to see a more complete
working example of DataConn in action (ie. within port context).  This
seems like a really powerful feature inside AEMP, but maybe still a bit
undeveloped.


thanks in advance,

-gleeco


------------server-code--------------
{
    my $cv = AE::cv;

    configure nodeid => "fark.$$";
    grp_reg Busytown     => "fark.$$";
    warn( "port fark_server.$$ is live ");

    $cv->wait;
}

sub Fark::data_conn {
    my ($one, $hdl) = @_;
    warn( "data_conn fires; conn established ref=", ref $hdl );
    $hdl->push_read(  line => sub {
        _warn( "got data_conn DATA ");
    });
}



----client-code-------------

{
    my $cv = AE::cv;

    configure;
    my $px = port;
    my $rx;

    my $g; $g = AE::timer 1, 1, sub {
        $rx = grp_get "Busytown" or return;

        warn( "checking global -- ", JSON::XS->new->pretty->encode(
\%AnyEvent::MP::Global::addr)  );

        peval $px, sub {
            AnyEvent::MP::DataConn::connect_to $rx->[0], 5,
"Fark::data_conn", 1, sub {
              my ($hdl) = @_;
              warn( " data_conn starting send from client PX=$px handle=" .
ref $hdl );
              $hdl->on_error( sub { warn( "hdl is fucked: $_[2] " ); undef
$hdl } );
                for (1..3){
                    $hdl or (warn("no handle on $_" ) and last );
                    $hdl->push_write( " data_conn via push_write $_\n" );
                    warn("sending msg.$_ ");
                }
            };
        };
        undef $g;
    };
    $cv->wait;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20120614/f1692089/attachment.html>


More information about the anyevent mailing list