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
<?php | |
if (function_exists('pcntl_fork')) { | |
$chunks = ['A', 'B', 'C', 'D']; | |
foreach ($chunks as $chunk) { | |
$pid = pcntl_fork(); | |
if ($pid == -1) die("Error al crear proceso hijo.\n"); | |
elseif ($pid) continue; // proceso padre | |
else { | |
process($chunk); | |
exit(); |
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
<?php | |
chdir(__DIR__); | |
$http = new swoole_http_server('php', 8080); | |
$http->on('start', function ($server) { | |
echo "Server has been started!\n"; | |
}); | |
$http->on('request', function ($request, $response) { | |
swoole_async_readfile('index.html', function($filename, $content) use ($response) { |