#!/usr/bin/env perl use strict; use warnings; use IO::Socket; my $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => '127.0.0.1', PeerPort => "9898", ); unless ($remote) { die "cannot connect" } $remote->autoflush(1); print $remote "client $$\n"; while ( <$remote> ) { print;last; } close $remote; print "Socket gone, exiting\n";