Echo server: Difference between revisions
Content added Content deleted
m (→{{header|LFE}}: Fixed typo) |
m (→{{header|Perl 6}}: "async" is now "start") |
||
Line 1,335: | Line 1,335: | ||
By default it spawns 5 child processes at startup, makes sure there are always at least 2 and at most 10 spare children available for new requests, each of which will be killed after processing 1000 requests and new ones will take their place. |
By default it spawns 5 child processes at startup, makes sure there are always at least 2 and at most 10 spare children available for new requests, each of which will be killed after processing 1000 requests and new ones will take their place. |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|rakudo|2015-09-09}} |
|||
<lang perl6>my $socket = IO::Socket::INET.new: |
<lang perl6>my $socket = IO::Socket::INET.new: |
||
localhost => 'localhost', |
localhost => 'localhost', |
||
Line 1,342: | Line 1,343: | ||
while $socket.accept -> $conn { |
while $socket.accept -> $conn { |
||
say "Accepted connection"; |
say "Accepted connection"; |
||
start { |
|||
while $conn.recv -> $stuff { |
while $conn.recv -> $stuff { |
||
say "Echoing $stuff"; |
say "Echoing $stuff"; |
||
Line 1,350: | Line 1,351: | ||
} |
} |
||
}</lang> |
}</lang> |
||
This is supposed to work, but <tt>async</tt> is currently busted. Substituting <tt>do</tt> will allow it to limp along as a single-threaded server. |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |