Posted on February 14, 2019 at 10:52 pm
Sometimes gethostbyname() can take up to 5 seconds and more to complete.
Here are two smart tricks to make it faster:
// Set timeout and retries to 1 to have a max execution time of 1 second for the DNS lookup putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1'); // Make sure the domain ends in a dot to prevent DNS recursion lookups $ip = @gethostbyname("google.com.");
Thansk to Dennis for these awesome tips:
It works also with gethostbyaddr().
Updated on April 16, 2019 at 11:36 pm
- Linux Move Files and Overwrite Existing Files
- PHP Curl slow with HTTPS SSL requests
- mv: Directory not empty
- Detect a failing hard-disk on a Linux server
- Certbot.errors.CertStorageError: expected to be a symlink
- Example hard-disk error logs on a Linux server
- Certbot renew error: Account at does not exist.
- Compress Word, Excel and PowerPoint Office Documents
- Minify & Compress CSS with online tools
- Upload a File via POST with cURL and PHP 7
- Compress MP4 videos online for free
- Download Old Sent Emails on POP Account with Thunderbird
- Automatically Renew Let's Encrypt Certificates (Nginx)
- Problems with /etc/cron.d/certbot on Debian
- Let's Encrypt on Nginx and SSL Grade A+
- Install a package from backports on Debian