xref: /minix3/external/bsd/bind/dist/bin/tests/system/send.pl (revision 00b67f09dd46474d133c95011a48590a8e8f94c7)
1*00b67f09SDavid van Moolenbroek#!/usr/bin/perl
2*00b67f09SDavid van Moolenbroek#
3*00b67f09SDavid van Moolenbroek# Copyright (C) 2004, 2007, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
4*00b67f09SDavid van Moolenbroek# Copyright (C) 2001  Internet Software Consortium.
5*00b67f09SDavid van Moolenbroek#
6*00b67f09SDavid van Moolenbroek# Permission to use, copy, modify, and/or distribute this software for any
7*00b67f09SDavid van Moolenbroek# purpose with or without fee is hereby granted, provided that the above
8*00b67f09SDavid van Moolenbroek# copyright notice and this permission notice appear in all copies.
9*00b67f09SDavid van Moolenbroek#
10*00b67f09SDavid van Moolenbroek# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11*00b67f09SDavid van Moolenbroek# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12*00b67f09SDavid van Moolenbroek# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13*00b67f09SDavid van Moolenbroek# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14*00b67f09SDavid van Moolenbroek# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15*00b67f09SDavid van Moolenbroek# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*00b67f09SDavid van Moolenbroek# PERFORMANCE OF THIS SOFTWARE.
17*00b67f09SDavid van Moolenbroek
18*00b67f09SDavid van Moolenbroek# Id: send.pl,v 1.7 2011/03/05 23:52:29 tbox Exp
19*00b67f09SDavid van Moolenbroek
20*00b67f09SDavid van Moolenbroek#
21*00b67f09SDavid van Moolenbroek# Send a file to a given address and port using TCP.  Used for
22*00b67f09SDavid van Moolenbroek# configuring the test server in ans.pl.
23*00b67f09SDavid van Moolenbroek#
24*00b67f09SDavid van Moolenbroek
25*00b67f09SDavid van Moolenbroekuse IO::File;
26*00b67f09SDavid van Moolenbroekuse IO::Socket;
27*00b67f09SDavid van Moolenbroek
28*00b67f09SDavid van Moolenbroek@ARGV == 2 or die "usage: send.pl host port [file ...]\n";
29*00b67f09SDavid van Moolenbroek
30*00b67f09SDavid van Moolenbroekmy $host = shift @ARGV;
31*00b67f09SDavid van Moolenbroekmy $port = shift @ARGV;
32*00b67f09SDavid van Moolenbroek
33*00b67f09SDavid van Moolenbroekmy $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port,
34*00b67f09SDavid van Moolenbroek				 Proto => "tcp",) or die "$!";
35*00b67f09SDavid van Moolenbroekwhile (<>) {
36*00b67f09SDavid van Moolenbroek	$sock->syswrite($_, length $_);
37*00b67f09SDavid van Moolenbroek}
38*00b67f09SDavid van Moolenbroek
39*00b67f09SDavid van Moolenbroek$sock->close;
40