Hi. I'm using Amazon SNS to send/receive HTTP notifications. Sending works ok but for receiving, I need a simple socket server that would accept inbound HTTP messages. I created this (quick & dirty)
#!/usr/bin/perl -w use IO::Socket; use strict; # Turn on autoflushing $| = 1; my $port = 54321; my $server = IO::Socket->new( Domain => PF_INET, Proto => 'tcp', LocalPort => $port, Listen => SOMAXCONN, Reuse => 1, ); die "Bind failed: $!\n" unless $server; my $new_sock = $server->accept(); while(<$new_sock>) { print $_ . "\n"; } close($server);
However, what happens is that I get ALL of the data incoming EXCEPT that very last byte. The last byte is a squiggly } and I don't get it until much later. It's really strange. And then Amazon attempts to resend the message again. So, it ends up getting all screwed up. I have a feeling accepting raw TCP packets is not the right way, that I'm missing something inherent to HTTP. What am I doing wrong, can you please help? Thank you.

In reply to problems accepting HTTP packets from Amazon by coontie

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.