-
-
Save jberger/91e39455f77a077baa2e30f4b51d2ca5 to your computer and use it in GitHub Desktop.
RFC865 compliant QOTD server using Mojo::IOLoop. See also https://tools.ietf.org/html/rfc865
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojo::IOLoop; | |
my $server = Mojo::IOLoop->server({address => '127.0.0.1', port => 17}, sub { | |
my ($loop, $stream, $id) = @_; | |
$loop->subprocess(sub{ scalar `fortune -n 512 -s` }, sub { | |
my (undef, $err, $qotd) = @_; | |
$stream->write($qotd, sub { shift->close }); | |
}); | |
}); | |
Mojo::IOLoop->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment