This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 4.0 patch 18: patch #11, continued
[perl5.git] / client
1 #!./perl
2
3 $pat = 'S n C4 x8';
4 $inet = 2;
5 $echo = 7;
6 $smtp = 25;
7 $nntp = 119;
8 $test = 2345;
9
10 $SIG{'INT'} = 'dokill';
11
12 $this = pack($pat,$inet,0,   128,149,13,43);
13 $that = pack($pat,$inet,$test,127,0,0,1);
14
15 if (socket(S,2,1,6)) { print "socket ok\n"; } else { die $!; }
16 if (bind(S,$this)) { print "bind ok\n"; } else { die $!; }
17 if (connect(S,$that)) { print "connect ok\n"; } else { die $!; }
18
19 select(S); $| = 1; select(stdout);
20
21 if ($child = fork) {
22     while (<STDIN>) {
23         print S;
24     }
25     sleep 3;
26     do dokill();
27 }
28 else {
29     while (<S>) {
30         print;
31     }
32 }
33
34 sub dokill { kill 9,$child if $child; }