In a fairly simple server (simulator; the actual guts aren't there, just the server infrastructure) using INET sockets running on Centos, I'm getting <$sock> returning undef with $! blank. SIGPIPE is ignored. I'm running out of ideas.

This chunk of code is in a subroutine, called to do all the input from the client:

$iologger->debug("socket blocking state ", $sock->blocking()); my $l = <$sock>; my $err = $!; $iologger->debug("Client input call err ", safe($err), " line ", safe($l)); if (!defined($l)) { my $d = Dumper($sock); $iologger->debug("Socket at error: $d"); die "eiread failed: $err"; } $iologger->info("Client input: ", safe($l)); return $l;

("safe()" is a function that turns undef into "[undef]" and an empty string into "[empty]" and passes through a non-empty string; so the log shows more clearly what's happening.)

Log output below shows it reading a number of lines, down to "h1,h2", and then on the next read call getting undef back. How can it get undef back, without $! being set? (The "Bad file descriptor" messages are lingering $! values, being reported when <$sock> returned a value, and hence don't mean anythying. The code is logging the $! value even when it's not meaningful. Lazy debug code, okay?)

2011-09-27 17:23:14,723 INFO simkserver: Accepted cmdcnt 1 starttime +17:23:14 2011-09-27 17:23:14,744 DEBUG simkserver.io: socket blocking state 1 2011-09-27 17:23:14,745 DEBUG simkserver.io: Client input call err Bad + file desc riptor line Proxy,127.0.0.1 2011-09-27 17:23:14,746 INFO simkserver.io: Client input: Proxy,127.0 +.0.1 2011-09-27 17:23:14,746 INFO simkserver: Connection is from proxy for + 127.0.0.1 2011-09-27 17:23:14,747 DEBUG simkserver.io: socket blocking state 1 2011-09-27 17:23:14,747 DEBUG simkserver.io: Client input call err Bad + file desc riptor line foo,3 2011-09-27 17:23:14,748 INFO simkserver.io: Client input: foo,3 2011-09-27 17:23:14,748 DEBUG simkserver: command foo arg1 3 2011-09-27 17:23:14,749 DEBUG simkserver.io: socket blocking state 1 2011-09-27 17:23:16,557 DEBUG simkserver.io: Client input call err Bad + file desc riptor line h1,h2 2011-09-27 17:23:16,574 INFO simkserver.io: Client input: h1,h2 2011-09-27 17:23:16,575 DEBUG simkserver.io: socket blocking state 1 2011-09-27 17:23:16,575 DEBUG simkserver.io: Client input call err [em +pty] line [undef] 2011-09-27 17:23:16,576 DEBUG simkserver.io: Socket at error: $VAR1 = +bless( \*S ymbol::GEN1, 'IO::Socket::INET' ); 2011-09-27 17:23:16,577 ERROR simkserver: Aborted transaction on excep +tion eirea d failed: at ./simkserver line 103, <GEN1> line 3.

(The logging calls are log4perl.)


In reply to "Impossible" socket error return by dd-b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.