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