On Wed, 15 Dec 2004 16:59:35 +0100 Sven Neuhaus <[EMAIL PROTECTED]> wrote:
> Can we beat them (in perl)? > http://www.freedom-to-tinker.com/tinyp2p.html I believe this is not fun :) Using libraries etc ruins the golf scent unless strict description. However without investigating the tinyp2p which lacks description what it exactly does, I came up with those: # pps.pl server--returns file name and data by regexp from current dir #!/usr/bin/perl use IO::Socket::INET; use IO::All; my $sr=$sock = IO::Socket::INET->new(Listen => 5, LocalAddr => 'localhost:9999', ReuseAddr => 1 ); while(4) { my $cl = $sr->accept() or next; $re = <$cl>; chop($re); my @f = grep /$re/, <*>; my $n = shift @f; my $d < io $n; print $cl "$n\n"; print $cl $d; } # 400 bytes approx. and # ppc.pl client--requests file by regexp and save under the server-offered name #!/usr/bin/perl use IO::Socket::INET; use IO::All; my $cl = IO::Socket::INET->new( PeerAddr => "$ARGV[0]:9999") or die "connect error\n"; $| = 1; print $cl "$ARGV[1]\n"; $n = <$cl>; chop($n); $/=undef; <$cl> > io $n; # 200 bytes approx. both are *FAR* from perfect, there are so many issues like security, redirection etc. but still a shot into plain client/server httpd direction :))) P! Vladi. -- Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Personal home page at http://cade.datamax.bg/ DataMax SA http://www.datamax.bg there is still one truth on which we can depend we've started something we can never end
pps.pl
Description: Binary data
ppc.pl
Description: Binary data
pgpFxQsdUlqfI.pgp
Description: PGP signature