toadi has asked for the wisdom of the Perl Monks concerning the following question:
Ok Ok, no use strict, but is just a small piece of example code.#!/usr/bin/perl -w use IO::Socket; use Net::hostent; $PORT = 9000; $server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $PORT, Listen => SOMAXCONN, Reuse => 1); die "can't setup server" unless $server; print "[Server $0 accepting clients]\n"; while ($client = $server->accept()) { $client->autoflush(1); print $client "Welcome to $0.\n"; $hostinfo = gethostbyaddr($client->peeraddr); printf "[Connect from %s]\n", $hostinfo->name || $client->peerho +st; system('./sleep.pl'); close $client; }
Edit: chipmunk 2001-12-11
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wait for next
by MZSanford (Curate) on Dec 11, 2001 at 21:26 UTC | |
|
Re: Wait for next
by Rhandom (Curate) on Dec 11, 2001 at 22:07 UTC | |
|
Wait for it . . .
by Fletch (Bishop) on Dec 11, 2001 at 23:05 UTC |