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

frankus has asked for the wisdom of the Perl Monks concerning the following question:

I've just rolled my own server ( in C because it ties into C APIs ). I'm writing a client in Perl to sit on another machine and interogate it.

The problem is, that I can telnet to the server and the server works, returning the grid reference for a location or postcode.

Using the Perl, client the data is sent and the server replies (I can see that from the server log) but the data data doesn't appear back on the client, untill I close the server down, presumably closing the pipe.

I know I've done something fundamentally stoopid, what is it?

Here is the code:

#!/usr/local/bin/perl use strict; use warnings; use IO::Socket; use Data::Dumper; $|=1; my $remote_host = '1XX.1XX.XX.XX'; my $remote_port = 1139; my $socket = IO::Socket::INET->new ( PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM ) or die "Couldn't connect to $remote_host:$remote_port +: $@\n"; $socket->autoflush(1); while (<>){ print $socket $_; my @answer = <$socket>; print Dumper \@answer; } close( $socket );

--

Brother Frankus.

¤