Skip to content

Instantly share code, notes, and snippets.

@tony-o
Created April 6, 2015 00:07
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 tony-o/ad52076865a21edec940 to your computer and use it in GitHub Desktop.
Save tony-o/ad52076865a21edec940 to your computer and use it in GitHub Desktop.
IO::Socket::INET Behaving Badly
#!/usr/bin/env perl6
use Test;
my $server = IO::Socket::INET.new(:localhost<127.0.0.1>, :localport(8091), :listen);
my $supply = Supply.new;
my $promise = start({
my $conn = $server.accept;
$supply.emit($conn);
});
$supply.tap(-> $conn {
my $data = '';
'Starting to receive.'.say;
while my $d = $conn.recv {
$data ~= $d;
}
'Never get\'s to this line.'.say;
ok $data eq 'Hello, perl6.';
});
my $conn = IO::Socket::INET.new(:host<127.0.0.1>, :port(8091));
'Connection sending data.'.say;
$conn.send('Hello, perl6.');
await $promise;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment