Advertisement
Brandan

Untitled

Oct 28th, 2012
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.69 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. #use strict;
  5. use IO::Socket::INET;
  6. use IO::Select;
  7.  
  8. $| = 1;
  9.  
  10. $socket = new IO::Socket::INET (
  11.     LocalHost => '0.0.0.0',
  12.     LocalPort => '4005',
  13.     Proto => 'tcp',
  14.     Listen => 100,
  15.     Reuse => 1
  16.     ) or die "ERROR in Socket Creation : $!\n";
  17.  
  18. $select = IO::Select->new($socket) or die "IO::Select $!";
  19.  
  20. while(1) {
  21.     @ready_clients = $select->can_read(1);
  22.     foreach my $fh (@ready_clients)  {
  23.     if($fh == $socket)       {
  24.         my $new = $socket->accept();
  25.         $select->add($new);
  26.     } else {
  27.         my $data=<$fh>;
  28.     if(!$data) {
  29.                 print "DISCON\n";
  30.                 $fh->close;
  31.          }
  32.         if($data && $data =~ /lobcount/) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement