0) { stream_copy_to_stream($sock, $output, $content_length); } // send response $fd = fopen($file, 'rb'); stream_copy_to_stream($fd, $sock); fclose($sock); } exit(0); } function http_server_sleep($socket_string, $micro_seconds = 500000) { if (!is_resource($server = http_server_init($socket_string, $output))) { return $server; } $sock = stream_socket_accept($server); if (!$sock) { exit(1); } usleep($micro_seconds); fclose($sock); exit(0); } function http_server_kill($pid) { posix_kill($pid, SIGTERM); pcntl_waitpid($pid, $status); } ?>