3 # edit this to the printer hostname
7 open(STDIN
, "$ARGV[0]") if $#ARGV >= 0;
12 #$hostname = hostname;
14 ($name, $aliases, $proto) = getprotobyname('tcp');
15 ($name, $aliases, $port) = getservbyname($port, 'tcp')
16 unless $port =~ /^\d+$/;
18 #$thisaddr = inet_aton($hostname);
19 #defined($thisaddr) or &errexit("inet_aton: cannot resolve $hostname\n");
21 $thataddr = inet_aton
($them);
22 defined($thataddr) or &errexit
("inet_aton: cannot resolve $them\n");
24 socket(S
, PF_INET
, SOCK_STREAM
, $proto) or &errexit
("socket: $!\n");
26 #$this = sockaddr_in(0, $thisaddr);
27 #bind(S, $this) || &errexit("bind: $!\n");
29 $that = sockaddr_in
($port, $thataddr);
30 connect(S
, $that) || &errexit
("connect: $!\n");
32 select(S
); $| = 1; select(STDOUT
);
38 vec($rin, fileno(S
), 1) = 1;
39 $nfound = select($rout=$rin, $wout=$rin, undef, undef);
40 if (vec($rout, fileno(S
), 1)) {
41 print STDERR
"$buffer\n" if
42 defined($nread = sysread(S
, $buffer, 8192));
44 if (vec($wout, fileno(S
), 1)) {
45 $nread = read(STDIN
, $buffer, 8192);
47 &errexit
("write: $!\n") unless
48 defined($written = syswrite(S
,$buffer,$nread));