Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/test.p6 Secret

Created May 23, 2017 13:52
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 jnthn/6f6168ad424a95624b39fe5b7dd007e1 to your computer and use it in GitHub Desktop.
Save jnthn/6f6168ad424a95624b39fe5b7dd007e1 to your computer and use it in GitHub Desktop.
use Test;
plan 5;
# MoarVM #165 (could not recv in a thread besides where the socket was
# accepted)
{
my $ready = Promise.new;
start {
my $listen = IO::Socket::INET.new(:listen, :localport(10334));
$ready.keep(True);
loop {
my $conn = $listen.accept;
start {
while my $buf = $conn.recv(:bin) {
$conn.write: $buf;
}
$conn.close;
}
}
}
await $ready;
for ^5 {
my $conn = IO::Socket::INET.new(:host<127.0.0.1>, :port(10334));
$conn.print: "Can be handled on a thread";
is $conn.recv, "Can be handled on a thread",
"Server with recv on different thread responded ($_)";
$conn.close;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment