That being said, if you have a huge networking task to do, it is much better to look at Event, ParallelForkManager, POE , or Stem to save yourself more than just time.#!/arudev/bin/perl use strict; use IO::Socket qw(:DEFAULT :crlf); $/ = CRLF; my ($bytes_out, $bytes_in, $quit); $SIG{INT} = sub { $quit++ }; my $port = $ENV{ARUFTPD_PORT} || die "ENV{ARUFTPD_POR} not defined"; my $sock = IO::Socket::INET->new( Listen => 20, LocalPort => $port, Timeout => 60*60, Reuse => 1 ) or die "Can't create listening socket: $!\n"; warn "waiting for incoming connection on port $port\n"; while (!$quit) { next unless my $session = $sock->accept; my $peer = gethostbyaddr($session->peeraddr,AF_INET) || $session->peerhost; my $port = $session->peerport; warn "Connection from [$peer,$port]\n"; my $msg = "230- *** SERVER IS DOWN FOR MAINTENANCE***\n"; print $session $msg; open A, '/m/aru/aruftpd/conf/aruftpd_welcome.text'; print $session "230- $_" while (<A>); print $session $msg; close $session; } close $sock;
And a final thing about this book is the author. Lincoln Stein is a very responsive person when you have an issue with his books or software, often getting back within one hour. And what else gets me is that this guy has an MD. I mean, I have 2 degrees in Comp. Sci. and one in Computational Neuroscience and I still can't touch his expertise in Perl. Damn!
In reply to Re: Network Programming With Perl
by princepawn
in thread Network Programming With Perl
by jeffa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |