Skip to content

Instantly share code, notes, and snippets.

@brianmed
Last active July 5, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmed/b70a1b3fb9ac6987790e46446e6fbd0e to your computer and use it in GitHub Desktop.
Save brianmed/b70a1b3fb9ac6987790e46446e6fbd0e to your computer and use it in GitHub Desktop.
Socket fun in perl 6
# echo -n "Joy\r\n\r\n" | nc 127.0.0.1 12321
# [bpm@Orfgum] c:~/playground>/opt/rakudo-star-2016.04/bin/perl6 --version
# This is Rakudo version 2016.04 built on MoarVM version 2016.04
# implementing Perl 6.c.
my $socket = IO::Socket::INET.new:
localhost => '127.0.0.1',
localport => 12321,
listen => 1;
while $socket.accept -> $conn {
say "Accepted connection";
start {
say "Started";
while $conn.recv -> $stuff {
say "Recv: $stuff";
}
$conn.close;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment