Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

send: Cannot determine peer address at ./toritv.pl line 183

by Anonymous Monk
on Jul 10, 2007 at 13:37 UTC ( [id://625820]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks. I am having a problem with a multiplexer i am writing, and i cannot seem to fin out what causes it. The error+message is "send: Cannot determine peer address at ./toritv.pl line 183". I've dumped the data to find out what the related variables are storing at the time of the crash, but i am not enlightened enhough to find the error. It should be added that this bu did not occur while the script was running on a FreeBSD 6.1 machine, but now that it is running on Linux 2.6.9 that bug has started to appear. Here is the code in question:
#======== toritv.pl ===================

foreach $client ($select->can_write(1)) {
        # Skip this client if we have nothing to say
        next unless exists $outbuffer{$client};
        $rv = $client->send($outbuffer{$client}, 0); # <-- this is where it crashes
        unless (defined $rv) {
                warn "I was told I could write, but I can't.\n";
                next;
        }
        # lots of code goes here...
}
  • Comment on send: Cannot determine peer address at ./toritv.pl line 183

Replies are listed 'Best First'.
Re: send: Cannot determine peer address at ./toritv.pl line 183
by moritz (Cardinal) on Jul 10, 2007 at 14:01 UTC
    You could tell us of what type $client is, and the Data::Dumper-Output of $outbuffer{$client} and $client.

    If it doesn't enlight you, maybe some other monk might find it usefull.

      Here is the dump for $client:
      == BEGIN datadump ==
      $VAR1 = \bless( \*Symbol::GEN10, 'IO::Socket::INET' );
      == END datadump ==
      
      The dump from %output is pretty big (70Kb), so instead of posting it here, i uploaded it to:
      http://www.clockworkninja.net/ffaa/outbuffer.dmp
        Looking into IO::Socket at http://search.cpan.org/src/GBARR/IO-1.2301/IO/Socket.pm reveals:

        sub send { @_ >= 2 && @_ <= 4 or croak 'usage: $sock->send(BUF, [FLAGS, [TO]] +)'; my $sock = $_[0]; my $flags = $_[2] || 0; my $peer = $_[3] || $sock->peername; croak 'send: Cannot determine peer address' unless($peer);

        So you have to take care that either peername is initialized on object creation, or provided the peer address as a third argument to send().

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://625820]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-10-06 22:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (43 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.