Created
December 28, 2014 20:19
-
-
Save hoelzro/d7d7b8056016292639ef to your computer and use it in GitHub Desktop.
Using a socket in a thread different from its creating thread
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 v6; | |
# run this script with the following running in a separate termainal | |
# (using OpenBSD netcat): | |
# | |
# nc -l localhost 9000 </dev/zero | |
my $sock = IO::Socket::INET.new( | |
:host<localhost>, | |
:port(9000), | |
); | |
my $p = start { | |
# this read will always be empty unless the socket creation is | |
# moved inside of the start block | |
say $sock.read(8); | |
42; | |
} | |
$p.result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment