I asked this question in the chatterbox and I couldn't get an answer ... so on the advice of a few monks I'll ask it here.

I found ... but lost ... an answer to a question on this site that teaches one how to set up a client/server comm.

This is the code that I grabbed:

#!/bin/Perl #This is the server side use strict; use IO::Socket; my $sock = new IO::Socket::INET (LocalPort => 1200, Proto => 'tcp', Listen => 5, Reuse => 1); die "Can't connect: $!\n" unless $sock; while (my $new_sock = $sock->accept()) { my $msg = <$new_sock>; print "client said '$msg'\n"; } close $sock; #Client Side use strict; use IO::Socket; my $sock = new IO::Socket::INET (PeerAddr => '127.0.0.1', PeerPort => 1200, Proto => 'tcp'); die "Can't create: $!\n" unless $sock; print $sock "send money!"; close $sock;

Aside from a few mis-placed commas ... which I fixed in the code above ... all worked well.

I extened the code to include:

for(my $i=0; $i <= 10; $i++) { print $sock "$i\n"; } print $sock "**** End of transmission ****";

When I run the script I get this:

'0 '

When I take out the /n I get: '0123456789****End Of Transmission****'

My Question: Why does the newline stop the data stream and what can I do to fix it??

Thanks in advance ....

Ducati

============================================

"We rock the body to rock the party ... until the party rocks the body"

De La Soul


In reply to Newline Character and Socket Comms by Ducati

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.