Last active
July 5, 2016 10:29
-
-
Save brianmed/b70a1b3fb9ac6987790e46446e6fbd0e to your computer and use it in GitHub Desktop.
Socket fun in perl 6
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
# 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