Skip to content

Instantly share code, notes, and snippets.

@brianmed
Created March 19, 2016 02:37
Show Gist options
  • Save brianmed/969ac29ebf0fe7d59843 to your computer and use it in GitHub Desktop.
Save brianmed/969ac29ebf0fe7d59843 to your computer and use it in GitHub Desktop.
IOLoop Server example
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