Subject: | read error: Connection reset by peer at... unbuffered reads problematic |
Date: | Tue, 17 Jul 2012 13:54:35 +1000 |
To: | bug-Net-Telnet [...] rt.cpan.org |
From: | Shaddy Baddah <beryllium [...] shaddybaddah.name> |
Hi,
I have an application that uses Net::Telnet to authenticate against a
server by telnet. Unfortunately, dependent on the target server, I
encounter:
read error: Connection reset by peer at...
It is true that the telnet server forces the connection closed.
Unfortunately when it does this my application is unable to read the
final lines of response from the server, due to this issue.
I had a look through Telnet.pm and note that the main system call for
reading back the data is sysread():
$nread = sysread $self, $s->{buf}, $s->{blksize}, $read_pos;
and from the documentation [http://perldoc.perl.org/functions/sysread.html]
I note that: "It bypasses buffered IO". This to me would account for the
problem I am facing.
I'm not suggesting using it is an error. In fact, I am fairly confident
there is a good reason for its use.
However, I think it is a bug that a check and read of any final data
sent by the remote peer has not been implemented; if possible with the
sysread() implementation; or otherwise, not to just use buffered I/O in
a way that allows for coverage of all data sent back.
--
Thanks,
Shaddy