server - perl6 Changes in IO::Socket::INET from last year and broken promises -
when asked question last year promises, echo server working (see link: perl6 how specific identity of promises? ). however, new versions of perl6, echo server no longer working.
i guess can try example perl6 documentation site ( https://docs.perl6.org/type/io::socket::inet ), want find out mistake have made in code. current level has precluded me seeing difference between codes , codes on perl6 documentation site. please give me hint; !
my @result; 0 .. 2 -> $index { @result[$index] = start { $mypromiseid = $index; "======> $mypromiseid\n"; $rssocket = io::socket::inet.new: localhost => 'localhost', localport => 1234 + $index, listen => 1; while $rssocket.accept -> $rsconnection { "promise $mypromiseid accepted connection"; while $rsconnection.recv -> $stuff { "promise $mypromiseid echoing $stuff"; $rsconnection.print($stuff); } $rsconnection.close; } } } await @result; and error messages are:
tried result of broken promise in block <unit> @ p6echomulti.pl line 24 original exception: nothing given new socket connect or bind in block @ p6echomulti.pl line 8 thrown at: in block @ p6echomulti.pl line 13
this commit, announced in jan 2017 section of rakudo's changelog "fixed bug ipv6 uris not parsed correctly" did lot more fix uri parsing bug. redid parameter binding/validation of io::socket::inet.new call, , 1 consequence broke code because updated code requires listen actual bool, not merely coerce one.
the old code (the code on left of commit link above) had simple method new (*%args copy). matched call. error (fail "nothing given new socket connect or bind to") did not trigger because 1 evaluates true in boolean context %args<host> || %args<listen> true. rest of code ran listen set 1 , worked out fine.
rakudos 2017.01 have code on right @ commit link above. note how there multiple new methods (i.e. multiple multi method new ... declarations).
the multi(s) intended handle call specifies listen argument is/are of form multi method new (..., bool:d :$listen!, ...). note bool:d.
a call new, listen parameter set true, matches multi , works expected.
but call :listen(1) match generic multi method new (*%args) signature instead. latter unconditional fail "nothing given new socket connect or bind to";.
Comments
Post a Comment