Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created December 28, 2014 20:19
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 hoelzro/d7d7b8056016292639ef to your computer and use it in GitHub Desktop.
Save hoelzro/d7d7b8056016292639ef to your computer and use it in GitHub Desktop.
Using a socket in a thread different from its creating thread
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