in reply to http Redirector

This is one of those programs that gets a bunch simpler when you use more modern interfaces. Programs that "use Socket" and nothing higher should generally be rewritten.
#!/usr/bin/perl use strict; use IO::Socket; my $s = IO::Socket::INET->new( LocalPort => 80, Listen => 5, Reuse => 1, MultiHomed => 1) or die; while (my $c = $s->accept) { print $c "HTTP/1.0 302 Over there\n"; print $c "Location: http://xxx.xxxxx.xxx\n\n"; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: http Redirector
by ginseng (Pilgrim) on Sep 24, 2001 at 04:56 UTC
    Merlyn, as always your code looks sweet. Thank you.

    I have used IO::Socket before, and would have preferred use it again. However, this machine is an antiquated (legacy) SCO server that is thoroughly broken. We fear change on this box, and instead are migrating all services away, to OpenBSD computers. This philosophy led me to use the internal socket instead.

    Regardless of my reasons, I agree that your code is preferable!

    Thank you also for the benchmarking. I had no idea that the performance difference would be so great. I had hoped to eke out just a few more requests. Sounds like it may handle dozens. Since the nimdA virus seems to hit servers with 16 requests at a time, we should be in good shape until we can take that box offline.