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.)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.