I seriously doubt you will get a helpful response to your question. What you have posted is far to "mocked up" and "simplified" for anyone to be able to guess what you are actually doing.

Simple example. You say:

Instead, I'm getting: command: cd hello command: cd world response: command: cd goodbye ...

But looking at the snippets you've posted, the first thing I notice is that the print statement that would be producing that response: trace is   print "resp: $responseData\n";, making your "actual output" nothing of the kind.

In addition, the logic of your sub:

sub sendData { my $request = $_[0]; $responseData = ""; #class member var print SOCKET "$request\n" . "\000" or die "print SOCKET: $!"; $responseData = <SOCKET>; ... print "resp: $responseData\n"; }

is such that there should be no way for your sends and receives to get out of sync as you follow each transmission with a blocking read.

Unless of course you have set the socket to be non-blocking, in which case, you should not be using the line-oriented diamond operator.

Add to that this line:

$responseData = ""; #class member var

which suggests that you think you are writing OO code but obviously are not, and that you are relying upon globals vars to convey data between subroutines, and it suggests that you have one unholy mess on your hands.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: TCP client buffering problems by BrowserUk
in thread TCP client buffering problems by ChopperCharles

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.