Some code (at last) 

sub run_command {
    my @files = map { File::Spec->rel2abs($_) } @_;

    my $command = $opt{command};
    my($alias, $gateway, $port) = connection_details();

    my $sock = IO::Socket::INET->new(PeerAddr => "$gateway:$port")
        or die "Can't connect to '$gateway:$port': $!\n";

    my $welcome = <$sock>;
    if(!$welcome or $welcome !~ /^200 READY/) {
        die "No listener?\n";
    }

    $sock->write(join qq{\x0A}, $alias, $command, @files, qq{\x0A})
        or die "Error sending command through backchannel: $!";
}