Last active
October 1, 2015 07:21
-
-
Save tokuhirom/0b6901f3cea1c3bf6170 to your computer and use it in GitHub Desktop.
perl6 react server stuck
This file contains hidden or 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 strict; | |
use warnings; | |
use utf8; | |
use 5.010000; | |
use IO::Socket::INET; | |
my $port = 3000; | |
my $n = 1000; | |
my $success = 0; | |
my $fail = 0; | |
for (1..$n) { | |
my $sock = IO::Socket::INET->new( | |
PeerHost => 'localhost', | |
PeerPort => $port, | |
Proto => 'tcp', | |
) or do { | |
print "cannot connect: $!\n"; | |
$fail++; | |
}; | |
my $got = <$sock>; | |
if (($got//'') eq "hello\n") { | |
$success++; | |
} else { | |
$fail++; | |
} | |
} | |
print "success:$success fail: $fail\n"; |
This file contains hidden or 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; | |
my $msg = "hello\n".encode('utf-8'); | |
react { | |
whenever IO::Socket::Async.listen('127.0.0.1', 3000) -> $conn { | |
$conn.write($msg).then({ $conn.close }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my environment, client.pl outputs
my environment is: