Created
March 19, 2016 02:37
-
-
Save brianmed/969ac29ebf0fe7d59843 to your computer and use it in GitHub Desktop.
IOLoop Server example
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
use Mojo::IOLoop::Server; | |
# Create listen socket | |
my $server = Mojo::IOLoop::Server->new; | |
$server->on(accept => sub { | |
my ($server, $handle) = @_; | |
print($handle "hello\r\n"); | |
}); | |
$server->listen(port => 3000); | |
$server->start; | |
$server->reactor->start unless $server->reactor->is_running; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment