Skip to content

Commit

Permalink
Merge pull request #37 from simula67/master
Browse files Browse the repository at this point in the history
Use the server ready flag file for discard test also
  • Loading branch information
simula67 committed Mar 29, 2014
2 parents 068ed16 + a55d4b2 commit 5bf4b14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions S32-io/IO-Socket-INET.pl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
if $server_or_client eq 'server' {
# warn "SERVER TEST=$test PORT=$port";
my $server = IO::Socket::INET.new(:localhost($host), :localport($port), :listen);
my $fd = open( $server_ready_flag_fn, :w );
$fd.close();
# warn "SERVER LISTENING";
while my $client = $server.accept() {
# warn "SERVER ACCEPTED";
Expand All @@ -66,9 +68,8 @@
}
else { # $server_or_client eq 'client'
# warn "CLIENT TEST=$test PORT=$port";
# avoid a race condition, where the client tries to
# open() before the server gets to accept().
sleep 1; # crude, sorry
until $server_ready_flag_fn.IO ~~ :e { sleep(0.1) }
unlink $server_ready_flag_fn;
my $client = IO::Socket::INET.new(:$host, :$port);
# warn "CLIENT OPENED";
$client.send( [~] '0'..'9', 'a'..'z' );
Expand Down

0 comments on commit 5bf4b14

Please sign in to comment.