[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
[MacPerl] Posted prematurely...
I guess I'm just doin' well today. I figured this one out in five minutes,
and for those who care, here's my very dirty (and not particularly mac-
oriented) script (but it works on a mac, which the original server in POD
didn't)...
#!/usr/bin/perl
use Socket;
use Carp;
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
$port = 23;
$proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto);
bind (Server, sockaddr_in($port, INADDR_ANY));
listen(Server,SOMAXCONN);
logmsg "server started on port $port";
for ( ; $paddr = accept(Client,Server); close Client) {
($port,$iaddr) = sockaddr_in($paddr);
$name = gethostbyaddr($iaddr,AF_INET);
logmsg "connection from $name [", inet_ntoa($iaddr), "] at port $port";
print Client "Hello there, $name, it's now ", scalar localtime,
"\015\012";
$mine = <Client>;
print Client "$mine\n";
}
- I hope you recognize what you're looking for when you find it.
***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch