home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PERL4036.ZIP / client < prev    next >
Text File  |  1993-02-08  |  602b  |  35 lines

  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; }
  35.