in reply to Error message in log file is different from "die" message in code.

Your code is dying because $new_connection is undefined, which means $server->accept returned an undefined value. The cause seems to be this:
if( $ready_socket == $server )
This looks like nonsense to me. You don't want a numerical comparison there (considering $server is an object reference). Where do you assign $ready_socket and what kind of thing does it contain?

Makeshifts last the longest.

  • Comment on Re: Error message in log file is different from "die" message in code.
  • Download Code

Replies are listed 'Best First'.
Re: Re: Error message in log file is different from "die" message in code.
by halley (Prior) on May 07, 2003 at 14:04 UTC
    if ($socket == $server), see perlref:
      Using a reference as a number produces an integer representing its storage location in memory. The only useful thing to be done with this is to compare two references numerically to see whether they refer to the same location.

    It's faster than using $socket eq $server because the arguments don't need to be converted to the "blessing=type" string format first.

    --
    [ e d @ h a l l e y . c c ]

Re: Re: Error message in log file is different from "die" message in code.
by Mask (Pilgrim) on May 07, 2003 at 13:14 UTC
    This is how $ready_socket created.
    527>($r_ready, $w_ready, $e_ready) = IO::Select->select($read_set, $wr +ite_set, undef, 10); 528> foreach my $ready_socket (@$r_ready) { 529> if( $ready_socket==$server ) { # Incomming connection 530> warn "Server socket ready, accepting..."; 531> my $new_connection=$server->accept(); 532> # make the socket non-blocking 533> my $flags = fcntl($new_connection, F_GETFL, 0) 534> or die "cannot get flags for socket: $!\n"; 535> $flags = fcntl($new_connection, F_SETFL, $flags | O_NONBLO +CK) 536> or die "cannot set flags for socket: $!\n";
    $server is created like this earlier.
    my $server = IO::Socket::INET->new(LocalPort => $cfg->server_port, Type => SOCK_STREAM, Reuse => 1, Listen => 10, ) or die "could not become a tcp server on port ", $cfg->server_port, +" : $@\n";
      That seems to be correct after some study of those modules' POD. The fact remains that $server->accept() is returning undef for failure - whatever the reason may be. Is there actually an external connection request at that point?

      Makeshifts last the longest.