-
-
Save jnthn/6f6168ad424a95624b39fe5b7dd007e1 to your computer and use it in GitHub Desktop.
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 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