Hello Perlmonks,
I am hoping to find some help for an issue I haven't been able to resolve on my own. I am relatively new to Perl but I had to make a socket connect to send a message then wait to receive the acknowledgment message before moving on. However, using the Perl book to guide me I am not able to read the response from the server correctly. All I get is a blank line on the first message and any following message I get the acknowledge message for the previous message.

After 1st transaction:
Received:

After 2nd transaction:
MSA|AA| MSH|^~\&|PFT|D|STAR|D|20110316115753|||JKH1157|P|2.2||||||

What I need to see is the acknowledge message for the particular message that was sent not the previous one. I am pretty sure this is a buffer block issue but still haven't been able to resolve it. I have included my code below.
#Create Socket socket(Impact, PF_INET, SOCK_STREAM, getprotobyname('tcp')); #Build the address of connection my $internet_addr = inet_aton("axtcnr") or die "Couldn't convert axtimpact into internet address\n"; my $paddr = sockaddr_in(6540, $internet_addr); #Connect connect(Impact,$paddr)or die "Couldn't conne +ct to axtimpact:6540 \n"; select ((select(Impact) , $| = 1)[0]); #enable command buffering if($msg =~ m{(\013.*\034\015)}smx){ print Impact $1; } shutdown(Impact,1); #read the remote answer my $server_message = do { local $/; <Impact>}; # get the response print "recieved: $server_message\n"; #Terminate the connection when done close(Impact);
Any help would be greatly appreciated. Thanks in advance.

In reply to Socket buffer issue by goosesganders

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.