Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: TCP client buffering problems

by BrowserUk (Patriarch)
on Oct 14, 2011 at 01:57 UTC ( [id://931414]=note: print w/replies, xml ) Need Help??


in reply to TCP client buffering problems

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://931414]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found