I have a simple server and client. I pulled the code right out of something else I have that works perfectly. In this pair, though, the server gets the first message and then nothing. The server does not hang or zombie, just does not get any more messages from the socket. The code is almost boilerplate from the books...any ideas? server socket code:
my $socket = IO::Socket::INET->new( LocalPort => 1880, Type => SOCK_STREAM, Reuse => 1, Listen => 10 ) or die "Big Problem with the Server, Man : $!\n\n"; while ( $test ) { my $date = localtime(); warn "Started up: $date\n"; while ( my $client = $socket->accept() ) { my $message = <$client> ; warn "$message"; chomp $message; print $client 'Message recieved', "\n" if $message; if ( $message eq 'die' ) { #etc., etc. } } }
then I have a little client I'm using to test it:
use IO::Socket::INET; my $socket; # for use in all scopes $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '1880', Proto => "tcp", Type => SOCK_STREAM) or die "Big Problem connecting to Server, Man : $!\n\n"; while (1) { print 'talk to me, like keyboards do: '; my $input = ; chomp $input; if ( $input =~ /^q/i ) { exit; } else { print $socket "$input\n"; } }
"A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche

In reply to socket sending/getting one message then nothing by jptxs

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.