Created
April 6, 2015 00:07
-
-
Save tony-o/ad52076865a21edec940 to your computer and use it in GitHub Desktop.
IO::Socket::INET Behaving Badly
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
#!/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