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'.<br>Basically, the std. aemp stuff works, just not the handle pushes as described in the perlpod. <br>
<br>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?<br>eg. <br><pre> 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</pre><br clear="all">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. <br>
<br><br>thanks in advance,<br><br>-gleeco<br><br><br>
------------server-code--------------<br>
{<br>
my $cv = AE::cv;<br>
<br>
configure nodeid => "fark.$$";<br>
grp_reg Busytown => "fark.$$";<br>
warn( "port fark_server.$$ is live ");<br>
<br>
$cv->wait;<br>
}<br>
<br>
sub Fark::data_conn {<br>
my ($one, $hdl) = @_;<br>
warn( "data_conn fires; conn established ref=", ref $hdl );<br>
$hdl->push_read( line => sub {<br>
_warn( "got data_conn DATA ");<br>
});<br>
}<br>
<br>
<br><br>----client-code-------------<br><br>{<br> my $cv = AE::cv;<br><br> configure;<br> my $px = port;<br> my $rx;<br><br> my $g; $g = AE::timer 1, 1, sub {<br> $rx = grp_get "Busytown" or return;<br>
<br> warn( "checking global -- ", JSON::XS->new->pretty->encode( \%AnyEvent::MP::Global::addr) );<br><br> peval $px, sub {<br> AnyEvent::MP::DataConn::connect_to $rx->[0], 5, "Fark::data_conn", 1, sub {<br>
my ($hdl) = @_;<br> warn( " data_conn starting send from client PX=$px handle=" . ref $hdl );<br> $hdl->on_error( sub { warn( "hdl is fucked: $_[2] " ); undef $hdl } );<br>
for (1..3){<br> $hdl or (warn("no handle on $_" ) and last );<br> $hdl->push_write( " data_conn via push_write $_\n" );<br> warn("sending msg.$_ ");<br>
}<br> };<br> };<br> undef $g;<br> };<br> $cv->wait;<br>}<br><br><br><br><br>