Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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