Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I used a little example in this book so that when my Net::FTPServer is down and someone FTP's to it, they get a little message saying "FTP Server is down":
#!/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;
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found