Ducati has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Zigster) Newline Character and Socket Comms
by zigster (Hermit) on May 04, 2001 at 19:13 UTC | |
by Ducati (Beadle) on May 04, 2001 at 21:49 UTC | |
|
Re: Newline Character and Socket Comms
by chorg (Monk) on May 04, 2001 at 19:40 UTC |