<?xml version="1.0" encoding="windows-1252"?>
<node id="35558" title="Re: Socket programming" created="2000-10-06 10:52:39" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="5539">
Jonathan</author>
<data>
<field name="doctext">
I would change the client side &lt;BR&gt;&lt;code&gt;
#!/usr/local/bin/perl
use IO::Socket;

# create a tcp connection to the specified host and port
$server = IO::Socket::INET-&gt;new( Proto     =&gt; "tcp",
PeerAddr  =&gt; 'localhost',
PeerPort  =&gt; '6969' ),
or die "can't connect to server: $!";


print "[Client $0 connected to server]\n";

print $server "READY\n";

while (defined ($this_line = &lt;$server&gt;)) {
    print STDOUT $this_line;
    if ($this_line =~ /STOP/i) { last; }
}
close $server;
&lt;/code&gt;
&lt;BR&gt;&lt;BR&gt;connects ok. On the server side I like to run with autoflush on. e.g. adding &lt;code&gt;use FileHandle;&lt;/code&gt;
and then &lt;code&gt;$server-&gt;autoflush(1);&lt;/code&gt; after you have opened the socket. I believe &lt;code&gt;select $server;$|=1&lt;/code&gt; will do the same thing.

&lt;BR&lt;BR&gt;&lt;BR&gt;
"We are all prompted by the same motives, all deceived by the same fallacies, all animated by hope, obstructed by danger, entangled by desire, and seduced by pleasure."
- Samuel Johnson</field>
<field name="root_node">
35554</field>
<field name="parent_node">
35554</field>
</data>
</node>
