home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / perl4036.zip / server < prev    next >
Text File  |  1993-02-08  |  571b  |  28 lines

  1. #!./perl
  2.  
  3. $pat = 'S n C4 x8';
  4. $inet = 2;
  5. $echo = 7;
  6. $smtp = 25;
  7. $nntp = 119;
  8.  
  9. $this = pack($pat,$inet,2345, 0,0,0,0);
  10. select(NS); $| = 1; select(stdout);
  11.  
  12. if (socket(S,2,1,6)) { print "socket ok\n"; } else { die $!; }
  13. if (bind(S,$this)) { print "bind ok\n"; } else { die $!; }
  14. if (listen(S,5)) { print "listen ok\n"; } else { die $!; }
  15. for (;;) {
  16.     print "Listening again\n";
  17.     if ($addr = accept(NS,S)) { print "accept ok\n"; } else { die $!; }
  18.  
  19.     @ary = unpack($pat,$addr);
  20.     $, = ' ';
  21.     print @ary; print "\n";
  22.  
  23.     while (<NS>) {
  24.     print;
  25.     print NS;
  26.     }
  27. }
  28.