#!/usr/bin/env perl -s [--r={remote server} --l={local address}|--f={filename localaddress}]
$a=$l? #if $r, copy address into $a
#using bitwise or as we only need to make sure all ops are done
$k{$r}=1|socket(S,2,1,6)| #open a socket
bind(S,&a)| #bind to localhost

# handle input
:
#get a file
&t# [?]


sub a { #shamelessly nicked from molester
   $l=~/:/;
   pack'CxnC4x8',2,$',split'\.',$`
}


#may not be useful

sub t {
   socket X,2,1,6;
   $k{$w}&&=(connect C,&a)?print C"$, ".pop:$0;
   # must close C here because the peer is waiting and we might end up
   # waiting for the peer (deadlock)
   close C
}

sub f {
   $w=$_,t"$1 $3/"for keys%k
}