From e72f13916bab5dc03c3abfb853414d17a72bf695 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 5 Jan 2023 01:02:22 +0100 Subject: [PATCH] Replace 3rd party domains in examples with example.com While using a big tech 3rd party domain like google.com is guaranteed to work, there are special domains like example.com set up for this since the dawn of the internet. --- examples/13-http-client-blocking.php | 6 +++--- examples/14-http-client-async.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/13-http-client-blocking.php b/examples/13-http-client-blocking.php index f0562c90..ae119b5a 100644 --- a/examples/13-http-client-blocking.php +++ b/examples/13-http-client-blocking.php @@ -4,16 +4,16 @@ require __DIR__ . '/../vendor/autoload.php'; -// connect to www.google.com:80 (blocking call!) +// connect to example.com:80 (blocking call!) // for illustration purposes only, should use react/socket instead -$stream = stream_socket_client('tcp://www.google.com:80'); +$stream = stream_socket_client('tcp://example.com:80'); if (!$stream) { exit(1); } stream_set_blocking($stream, false); // send HTTP request -fwrite($stream, "GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n"); +fwrite($stream, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n"); // wait for HTTP response Loop::addReadStream($stream, function ($stream) { diff --git a/examples/14-http-client-async.php b/examples/14-http-client-async.php index 074a0eac..93419c02 100644 --- a/examples/14-http-client-async.php +++ b/examples/14-http-client-async.php @@ -7,7 +7,7 @@ // resolve hostname before establishing TCP/IP connection (resolving DNS is still blocking here) // for illustration purposes only, should use react/socket or react/dns instead! -$ip = gethostbyname('www.google.com'); +$ip = gethostbyname('example.com'); if (ip2long($ip) === false) { echo 'Unable to resolve hostname' . PHP_EOL; exit(1); @@ -41,7 +41,7 @@ } // send HTTP request - fwrite($stream, "GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n"); + fwrite($stream, "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n"); // wait for HTTP response Loop::addReadStream($stream, function ($stream) {