from the side of vlc the socket stays "connected", while my cgi connects-sendsCommand-reads-terminates on each http request cycle.
The problem is with the -read- part, where my cgi can't detect so well if the issued command was answered correctly or not. On the interactive e.g. socat/netcat shell I (human) can easily see when a command is fully answered by the socket "stopping to spit out data". Anyway, my script can't be that smart.

vlc sends ~5-30 lines of answer data, each terminated by \n. That's why I try to detect common "last lines" of output - but as said, it doesn't work on every output.
Is there a way to limit my read to, let say, max 100 lines?
Or a common algorithm to set timeouts on read-while loops?

In reply to Re^2: Chunked unix socket file reading - how? by Anonymous Monk
in thread Chunked unix socket file reading - how? by Anonymous Monk

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.