Fellow Monks,
I've reached an interesting question while designing a module to facilitate collecting and parsing TL1 output, though not related to TL1 itself, but rather to the behavior of Net::Telnet.
Disclaimer: I'm not stricken with NIH syndrome. I've evaluated both Net::TL1 and the non-CPAN TL1 modules (code and functionality) and neither seems to fit my needs.
My question requires a smattering of context. The TL1 data I am interested in is sent autonomously, over a telnet-like session. There is no log-in sequence. I simply connect and begin reading lines of input as they come, sometimes in torrents, sometimes nothing for minutes at a time.
The input is composed of multi-line 'messages' terminated by a semi-colon, on it's own line. Since the parsing of these is not important right now, I won't describe it any further.
What *is* important is that I am able to avoid losing *any* of these messages. Sometimes they come in, hundreds at a time, and other times there are none for minutes at a time. I don't like the idea of just looping forever, waiting for input and ignoring timeouts... but maybe I'm just being foolish :)
The question: I am curious as to how Net::Telnet collects input over the socket - if my program is busy processing a message and several new ones come in during that time, will I lose any before I get to the next readline()? Does Net::Telnet use select() and/or an internal buffer behind the scenes? Do I need to worry about the size of that buffer?
I must admit, I've already written a (rather ugly) module to solve this problem by using a thread to handle the reading and parsing of lines from the TL1 connection, which are then pushed onto a shared array for processing. It works well, but I'm not convinced it's the simplest solution, and the error-handling and recovery routines are the ugliest I've ever written! I am hunting for advice that will help me make this CPAN-worthy, and hopefully a lot simpler and more robust than I think it is right now.
I am a bit daunted by the code in Net::Telnet and what I('m looking for does not seem to be covered in the documentation or even elsewhere on the internet. I've poked around with select() and IO::Socket and IO::Select but I don't see the point in using those if Net::Telnet can handle the job for me.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.