This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change#3692 had an unintentional patch leak through!
[perl5.git] / eg / client
CommitLineData
a687059c
LW
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
15if (socket(S,2,1,6)) { print "socket ok\n"; } else { die $!; }
16if (bind(S,$this)) { print "bind ok\n"; } else { die $!; }
17if (connect(S,$that)) { print "connect ok\n"; } else { die $!; }
18
19select(S); $| = 1; select(stdout);
20
21if ($child = fork) {
21d892ea 22 while (<STDIN>) {
a687059c
LW
23 print S;
24 }
25 sleep 3;
26 do dokill();
27}
28else {
29 while (<S>) {
30 print;
31 }
32}
33
34sub dokill { kill 9,$child if $child; }