PHP code example of kelunik / retry
1. Go to this page and download the library: Download kelunik/retry library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kelunik / retry example snippets
use Amp\Loop;
use Kelunik\Retry\ConstantBackoff;
use function Kelunik\Retry\retry;
ld retry(3, function () {
return Amp\Socket\cryptoConnect("tcp://github.com:443");
}, Amp\Socket\SocketException::class, new ConstantBackoff(1000));
yield $socket->write("GET / HTTP/1.0\r\nhost: github.com\r\n\r\n");
$buffer = "";
while (null !== $chunk = yield $socket->read()) {
$buffer .= $chunk;
if (strpos($buffer, "\r\n\r\n") !== false) {
print strstr($buffer, "\r\n\r\n", true);
break;
}
}
$socket->close();
});