http://www.perlmonks.org?node_id=35558


in reply to Socket programming

I would change the client side
#!/usr/local/bin/perl use IO::Socket; # create a tcp connection to the specified host and port $server = IO::Socket::INET->new( Proto => "tcp", PeerAddr => 'localhost', PeerPort => '6969' ), or die "can't connect to server: $!"; print "[Client $0 connected to server]\n"; print $server "READY\n"; while (defined ($this_line = <$server>)) { print STDOUT $this_line; if ($this_line =~ /STOP/i) { last; } } close $server;


connects ok. On the server side I like to run with autoflush on. e.g. adding use FileHandle; and then $server->autoflush(1); after you have opened the socket. I believe select $server;$|=1 will do the same thing. <BR

"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