File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
require __DIR__ . '/../vendor/autoload.php ' ;
6
6
7
- // connect to www.google .com:80 (blocking call!)
7
+ // connect to example .com:80 (blocking call!)
8
8
// for illustration purposes only, should use react/socket instead
9
- $ stream = stream_socket_client ('tcp://www.google .com:80 ' );
9
+ $ stream = stream_socket_client ('tcp://example .com:80 ' );
10
10
if (!$ stream ) {
11
11
exit (1 );
12
12
}
13
13
stream_set_blocking ($ stream , false );
14
14
15
15
// send HTTP request
16
- fwrite ($ stream , "GET / HTTP/1.1 \r\nHost: www.google .com \r\nConnection: close \r\n\r\n" );
16
+ fwrite ($ stream , "GET / HTTP/1.1 \r\nHost: example .com \r\nConnection: close \r\n\r\n" );
17
17
18
18
// wait for HTTP response
19
19
Loop::addReadStream ($ stream , function ($ stream ) {
Original file line number Diff line number Diff line change 7
7
8
8
// resolve hostname before establishing TCP/IP connection (resolving DNS is still blocking here)
9
9
// for illustration purposes only, should use react/socket or react/dns instead!
10
- $ ip = gethostbyname ('www.google .com ' );
10
+ $ ip = gethostbyname ('example .com ' );
11
11
if (ip2long ($ ip ) === false ) {
12
12
echo 'Unable to resolve hostname ' . PHP_EOL ;
13
13
exit (1 );
41
41
}
42
42
43
43
// send HTTP request
44
- fwrite ($ stream , "GET / HTTP/1.1 \r\nHost: www.google .com \r\nConnection: close \r\n\r\n" );
44
+ fwrite ($ stream , "GET / HTTP/1.1 \r\nHost: example .com \r\nConnection: close \r\n\r\n" );
45
45
46
46
// wait for HTTP response
47
47
Loop::addReadStream ($ stream , function ($ stream ) {
You can’t perform that action at this time.
0 commit comments