Skip to content

Commit

Permalink
Replace 3rd party domains in examples with example.com
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
WyriHaximus committed May 2, 2023
1 parent 1f3f6b9 commit e72f139
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/13-http-client-blocking.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions examples/14-http-client-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e72f139

Please sign in to comment.