Hello, I realize that there's been a few very similar threads on hanging sockets but none of the fixes that worked for others seem to work for this issue, so I thought I'd add it to the heap.

I've got a POE TCP server running on localhost on a Windows box with ActivePerl 5.8.8. A pure-POE client-server setup works fine. Both sides can read/write. However on the client side I just want a simple connect->write->read->disconnect. No need for the extra event handling. So I tried using IO::Socket::INET to do it. The problem is, no matter what I do the script hangs while trying to read from the socket. I've tried reading with <$socket> in a loop. I've tried it outside of a loop. I've tried sysread($socket, $buf, 1024) in and out of a loop. I've tried doing shutdown($socket, 1). I've tried setting $/ to some other string and passing it through the server and it still hangs. Right now the code looks like this:
use IO::Socket::INET; $socket = IO::Socket::INET->new( PeerAddr => '127.0.0.1', PeerPort => 5555, Proto => 'tcp', Type => SOCK_STREAM, Timeout => 5, ) or die $@; $socket->autoflush(1); print $socket "Hello!\n"; my $line = ""; sysread($socket, $line, 1024); print "ANSWER: " . $line; close($socket);
The server receives the "Hello!" and responds, but the client hangs on the sysread without ever receiving any data.

Thanks for taking the time to read this.

In reply to IO::Socket hanging in ActivePerl 5.8.8 by c0bra

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.