1#!/usr/bin/perl 2# 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, You can obtain one at http://mozilla.org/MPL/2.0/. 8# 9# See the COPYRIGHT file distributed with this work for additional 10# information regarding copyright ownership. 11 12# 13# Send a file to a given address and port using TCP. Used for 14# configuring the test server in ans.pl. 15# 16 17use IO::File; 18use IO::Socket; 19 20@ARGV == 2 or die "usage: send.pl host port [file ...]\n"; 21 22my $host = shift @ARGV; 23my $port = shift @ARGV; 24 25my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, 26 Proto => "tcp",) or die "$!"; 27while (<>) { 28 $sock->syswrite($_, length $_); 29} 30 31$sock->close; 32